lcl: use active form as parent for pmNone and modal windows. Issue #29635

git-svn-id: trunk@51597 -
This commit is contained in:
ondrej 2016-02-11 11:52:45 +00:00
parent 44e40b779d
commit 2c0c39f762
3 changed files with 18 additions and 11 deletions

View File

@ -1492,7 +1492,8 @@
</notes>
</element>
<element name="TPopupMode.pmNone">
<short>modal: popup to mainform/taskbar window; non-modal: no window parent</short>
<short>modal: popup to active form or if not available, to main form; non-modal: no window parent</short>
<descr>For modal windows, the handle has to be recreated in ShowModal. If this is not wanted, please use explicitely pmAuto before calling ShowModal.</descr>
</element>
<element name="TPopupMode.pmAuto">
<short>modal &amp; non-modal: popup to active form or if not available, to main form</short>

View File

@ -390,7 +390,7 @@ type
);
TPopupMode = (
pmNone, // modal: popup to mainform/taskbar window; non-modal: no window parent
pmNone, // modal: popup to active form or if not available, to main form; non-modal: no window parent
pmAuto, // modal & non-modal: popup to active form or if not available, to main form
pmExplicit // modal & non-modal: popup to PopupParent or if not available, to main form
);

View File

@ -1486,15 +1486,16 @@ begin
(PopupMode in [pmAuto, pmExplicit]) // set WndParent of non-modal windows only for pmAuto, pmExplicit
then
begin
case PopupMode of
pmAuto:
begin
Result := Screen.ActiveForm;
if (Result<>nil) and (Result.FormStyle = fsSplash) then // ignore fsSplash
Result := nil;
end;
pmExplicit: Result := PopupParent;
end;
if (PopupMode = pmAuto)
or ((PopupMode = pmNone) and (fsModal in FormState)) then
begin
Result := Screen.ActiveForm;
if (Result<>nil) and (Result.FormStyle = fsSplash) then // ignore fsSplash
Result := nil;
end else
if (PopupMode = pmExplicit) then
Result := PopupParent;
if (Result = nil) or not Result.HandleAllocated then
Result := Application.MainForm;
end;
@ -2900,6 +2901,11 @@ begin
Application.ModalStarted;
try
Include(FFormState, fsModal);
if PopupMode = pmNone then
begin
RecreateWnd(Self);
HandleNeeded;
end;
ActiveWindow := GetActiveWindow;
SavedFocusState := SaveFocusState;
SavedCursor := Screen.Cursor;