Delphi - the main form of the application is not focused correctly

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

Error 1. When you click "OK" from a specific printer form.

  • I open a preview of FastReports PDF - this is the first popup. This popup does not appear separately on the taskbar. This form is modal.
  • Then I press print,
  • This opens another window with standard printing options. A.
  • Then I click properties - this opens a specific form of the driver. I am changing the dual print setting. A.
  • When I click “OK”, the preview form (1) should be focused, but the main form is displayed in front . Since the preview form is still modal, it’s hard to get back to the preview form. Only by accidental clicks does the preview form focus again.

pressing


Mistake 2. Clicking or dragging this particular scroll focuses the main shape.

  • This window is active. This is a separate window on the Windows taskbar and is not modal. There is a gnostice pdf viewer in this form.
  • scrollbox, , . , pdf - . , , .

Error 2

. , :


?


:

  • : , : the shape seems big
  • .
  • MDI.
  • . .
  • VCLskin.
  • 1 5.6.1 5.6.8.
  • Windows 10.
  • Delphi XE 10.2.

Edit

  • . . , ( ).

, , . , , ,, @uwe-raabe.

. "":

Frm_DatabaseLogin.CreateForm(TFrm_MainMenu, Frm_MainMenu);

:

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

UpdateProgress .

, . , , .

+4
1

.

" " . TApplication Application.MainForm , Application.CreateForm.

, , "" .

, . , orverriding CreateParams, SetWindowLong, .

"" , .

CreateParams , :

procedure TMgrMain.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
  Params.WndParent := 0;
end;

(, ), PopupMode PopupParent. , , , .

procedure ShowAbout(Owner: TForm);
var
  LocalForm: TAbout;
begin
  LocalForm := TAbout.Create(Owner);
  try
    LocalForm.PopupMode := pmExplicit;
    LocalForm.PopupParent := Owner;
    LocalForm.ShowModal;
  finally
    FreeAndNil(LocalForm);
  end;
end;

PopupParent help:

PopupMode pmExplicit PopupParent nil, Application.MainForm PopupParent. Application.MainForm , Application.Handle PopupParent.

PopupMode pmAuto, Screen.ActiveForm PopupParent.

, , Peter Below newsgroup post. PopupParent/PopupMode

: borland.public.delphi.winapi
  : "Peter Below (TeamB)" < 100113.1... @compuXXserve.com >
  : 2000/11/30
  : Re: Modeless .exe

.. ..
, , . , , , , . , , , ( params.WndParent, ) , , ( Application.OnActivate, GetLastActivepopup Z- SetWindowPos).
 .. ..

, , , PopupMode PopupParent.

0

Source: https://habr.com/ru/post/1688998/


All Articles