mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 14:39:06 +02:00
win32: Open and Save dialogs will be shown at screen center now (issue #0010432)
git-svn-id: trunk@13368 -
This commit is contained in:
parent
90acad88f8
commit
c23094e75a
@ -33,7 +33,7 @@ uses
|
||||
// To get as little as posible circles,
|
||||
// uncomment only when needed for registration
|
||||
////////////////////////////////////////////////////
|
||||
LCLProc, LCLType, Dialogs, Controls, Graphics, SysUtils, Classes,
|
||||
LCLProc, LCLType, Dialogs, Controls, Graphics, SysUtils, Classes, Forms,
|
||||
////////////////////////////////////////////////////
|
||||
WSDialogs, WSLCLClasses, Windows, Win32Extra, Win32Int, InterfaceBase,
|
||||
Win32Proc;
|
||||
@ -142,7 +142,7 @@ function GetOwnerHandle(ADialog : TCommonDialog): HWND;
|
||||
begin
|
||||
with ADialog do
|
||||
begin
|
||||
if Owner Is TWinControl then
|
||||
if Owner is TWinControl then
|
||||
Result := TWinControl(Owner).Handle
|
||||
else
|
||||
Result := TWin32WidgetSet(WidgetSet).AppHandle;
|
||||
@ -235,14 +235,36 @@ end;
|
||||
type
|
||||
TWinFileDialogFunc = function(OpenFile: Windows.LPOPENFILENAME): WINBOOL; stdcall;
|
||||
|
||||
function OpenFileDialogCallBack(hwnd : Handle; uMsg : UINT; wParam: WPARAM;
|
||||
lParam: LPARAM) : UINT; stdcall;
|
||||
function OpenFileDialogCallBack(hWnd: Handle; uMsg: UINT; wParam: WPARAM;
|
||||
lParam: LPARAM): UINT; stdcall;
|
||||
|
||||
procedure Reposition(ADialogWnd: Handle);
|
||||
var
|
||||
Left, Top: Integer;
|
||||
DialogRect: TRect;
|
||||
begin
|
||||
// Btw, setting width and height of dialog doesnot reposition child controls :(
|
||||
// So no way to set another height and width at least here
|
||||
GetWindowRect(ADialogWnd, @DialogRect);
|
||||
|
||||
Left := (GetSystemMetrics(SM_CXSCREEN) - DialogRect.Right + DialogRect.Left) div 2;
|
||||
Top := (GetSystemMetrics(SM_CYSCREEN) - DialogRect.Bottom + DialogRect.Top) div 2;
|
||||
SetWindowPos(ADialogWnd, HWND_TOP, Left, Top, 0, 0, SWP_NOSIZE);
|
||||
end;
|
||||
|
||||
var
|
||||
OpenFileNotify: LPOFNOTIFY;
|
||||
OpenFileName: Windows.POPENFILENAME;
|
||||
NeededSize: SizeInt;
|
||||
DialogRec: POpenFileDialogRec;
|
||||
begin
|
||||
if uMsg = WM_INITDIALOG then
|
||||
begin
|
||||
// Windows asks us to initialize dialog. At this moment controls are not
|
||||
// arranged and this is that moment when we should set bounds of our dialog
|
||||
Reposition(GetParent(hWnd));
|
||||
end
|
||||
else
|
||||
if uMsg = WM_NOTIFY then
|
||||
begin
|
||||
OpenFileNotify := LPOFNOTIFY(lParam);
|
||||
@ -284,7 +306,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result:= 0;
|
||||
Result := 0;
|
||||
end;
|
||||
|
||||
function CreateFileDialogHandle(AOpenDialog: TOpenDialog): THandle;
|
||||
|
Loading…
Reference in New Issue
Block a user