From 8f5c37c13b2c903a048e3b1714203ebc108c7ac0 Mon Sep 17 00:00:00 2001 From: zeljko Date: Mon, 24 May 2010 16:34:13 +0000 Subject: [PATCH] Qt: qtdialogs - return focus to last active window, fixes #16535 git-svn-id: trunk@25613 - --- lcl/interfaces/qt/qtwsdialogs.pp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lcl/interfaces/qt/qtwsdialogs.pp b/lcl/interfaces/qt/qtwsdialogs.pp index e53f1896ed..223ebe9246 100644 --- a/lcl/interfaces/qt/qtwsdialogs.pp +++ b/lcl/interfaces/qt/qtwsdialogs.pp @@ -110,7 +110,7 @@ type implementation - +uses qtint; const QtDialogCodeToModalResultMap: array[QDialogDialogCode] of TModalResult = ( @@ -125,6 +125,9 @@ begin if ACommonDialog.Owner is TWinControl then Result := TQtWidget(TWinControl(ACommonDialog.Owner).Handle).Widget else + if (QtWidgetSet.GetActiveWindow <> 0) then + Result := TQtWidget(QtWidgetSet.GetActiveWindow).Widget + else if Assigned(Application.MainForm) and Application.MainForm.Visible then Result := TQtWidget(Application.MainForm.Handle).Widget else @@ -350,6 +353,7 @@ var selectedFilter, saveFileName, saveFilter, saveTitle: WideString; Flags: Cardinal; {$endif} + ActiveWin: HWND; begin {------------------------------------------------------------------------------ Initialization of variables @@ -373,6 +377,7 @@ begin if ACommonDialog is TSelectDirectoryDialog then QtFileDialog.setFileMode(QFileDialogDirectoryOnly); + ActiveWin := QtWidgetSet.GetActiveWindow; if ACommonDialog is TSaveDialog then begin {$ifdef QT_NATIVE_DIALOGS} @@ -482,6 +487,11 @@ begin end; {$endif} end; + if ActiveWin <> 0 then + begin + if QtWidgetSet.IsValidHandle(ActiveWin) then + QtWidgetSet.SetActiveWindow(ActiveWin); + end; end; { TQtWSSelectDirectoryDialog }