Home Delphi - Application main form gets focussed incorrectly
Reply: 0

Delphi - Application main form gets focussed incorrectly

user3008
1#
user3008 Published in July 23, 2018, 3:55 am

In two parts of my application, the main form gets focussed at the wrong moment:

Bug 1. When clicking 'OK' from a specific printer form.

  1. I open a FastReports PDF preview - that's the first popup. That popup is not shown seperately in the taskbar. This form is modal.
  2. Then I click print,
  3. That opens another window with standard printing options.
  4. Then I click properties - that opens the specific form of the driver. I change the double printing setting.
  5. When I click 'OK', the preview form (1) should be focussed, but the main form is brought to front. Because the preview form is still modal, it is hard to get back to the preview form. Only with random clicks, the preview form gets focussed again.


Bug 2. Clicking on or dragging this specific scrollbox focusses the main form

  1. This window is active. This is a seperated window in the Windows task bar and is not modal. There is a gnostice pdf viewer on this form.
  2. When I click the scrollbox to start dragging, the main form is brought to front. When I keep dragging, the scrolling at the pdf form still continues. Also, a tooltip near the mouse indicates what page is currently shown.

I want to solve this strange behaviour. So, my question is:


What can be causing these focussing bugs?


About the application:

  • I already noticed: the popup forms seems a bit too large, as you can see here:
  • see edit
  • Some forms are MDI child.
  • I searched in the code for all mouse events and put there breakpoints. But that code was not executed at the moment of the two bugs.
  • VCLskin is used.
  • Bug 1 occurs with Fast reports version 5.6.1 and 5.6.8.
  • Windows 10.
  • Delphi XE 10.2.

Edit

  • The application main form is set correctly. At startup, first a login form is shown. After your login, the datamodules are created, some forms are created without a owner (they are freed on application end).

All other forms, also the main form are owned by Application and not by the Login form. And indeed not as parent, but as owner, like @uwe-raabe said.

Then the main form is created. This is created via the Login form:

Frm_DatabaseLogin.CreateForm(TFrm_MainMenu, Frm_MainMenu);

That calls:

procedure TFrm_DataBaseLogin.CreateForm(InstanceClass: TComponentClass;
  var Reference);
begin
  Updateprogress(InstanceClass.ClassName);
  Application.CreateForm(InstanceClass,Reference);
end;

In UpdateProgress nothing special happens.

After that, the other forms are created too, owned by application. At the end, the login form hides and therefore the main form is shown.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.252891 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO