Alex
B&C wrote:
>
> Hi !
>
> How can I set the position of OpenDialog ? The following code doesn't
> work.
>
> with OpenDialog1 do begin Execute;
> SetWindowPos(Handle,HWND_NOTOPMOST,5,5,0,0,SWP_NOSIZE);
> end;
>
> Please send example. I think, I must use SendMessage to OpenDialog...
>
> Thanks for help.
The problem here is that the VCL code responsible for centering the dialog is
executed after the DoShow method (which fires the OnShow event). You did not
mention where you have placed the code to change the window dimensions, but
with a standard TOpenDialog the following works in the OnShow event:
procedure TForm1.OpenDialog1Show(Sender: TObject);
var
r: TRect;
begin
with sender as topendialog do begin
GetWIndowRect( GetParent( handle ), r );
MOveWindow( GetParent( handle ),
10, 10, r.right-r.left,
r.bottom-r.top, true );
Abort;
end;
end;
The Abort prevents the WM_NOTIFY message that triggered the OnShow event from
reaching the dialogs original window proc, which would pass it to the
ExplorerHook function in dialogs.pas, which does the centering if the
notification is CBN_INITDONE.
How can I set the position of OpenDialog ? The following code doesn't
work.
with OpenDialog1 do begin Execute;
SetWindowPos(Handle,HWND_NOTOPMOST,5,5,0,0,SWP_NOSIZE);
end;
Please send example. I think, I must use SendMessage to OpenDialog...
Thanks for help.
B&C