Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TOpenDialog Position ?

0 views
Skip to first unread message

Alexander Mueller

unread,
Jul 12, 1999, 3:00:00 AM7/12/99
to
This cant work as the dialog is closed when the program returns from
Execute. But unfortunately I also didnt get a solution. I tried to send
the dialog a WM_MOVE message but it ignored it. I think that the dialog
handle becomes valid when the dialog is executed and becomes invalid
when it is closed. So you would have to change the coordinates after
executing but before returning from execute. But these are just thoughts
;).

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.

KSG

unread,
Jul 12, 1999, 3:00:00 AM7/12/99
to
The following solution was originally posted by Peter Below:

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.

B&C

unread,
Jul 13, 1999, 3:00:00 AM7/13/99
to
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.


B&C

unread,
Jul 13, 1999, 3:00:00 AM7/13/99
to
many thanks, it works correctly now ;-)

B&C


0 new messages