lcl: better bullet-proof LCL approach for r51808 #cf74370262, issue #28631

git-svn-id: trunk@51810 -
This commit is contained in:
ondrej 2016-03-03 07:45:45 +00:00
parent 385957f10b
commit 2425ad6bff

View File

@ -28,9 +28,7 @@ function TCommonDialog.Execute: boolean;
var
DisabledList: TList;
SavedFocusState: TFocusState;
FocusedWindow: HWnd;
begin
FocusedWindow := GetFocus;
SavedFocusState := SaveFocusState;
DisabledList := Screen.DisableForms(Screen.ActiveForm);
try
@ -41,8 +39,9 @@ begin
finally
Screen.EnableForms(DisabledList);
RestoreFocusState(SavedFocusState);
if IsWindow(FocusedWindow) and (GetFocus<>FocusedWindow) then
SetFocus(FocusedWindow);
if (Screen.ActiveControl<>nil) and (Screen.ActiveControl.HandleAllocated)
and (GetFocus<>Screen.ActiveControl.Handle) then
SetFocus(Screen.ActiveControl.Handle); // must restore focus after Screen.EnableForms
end;
end;