Board index » delphi » set initial size and position for OpenDialog and SaveDialog

set initial size and position for OpenDialog and SaveDialog

I use the standard TOpenDialog and TSaveDialog D5 components with
the ofEnableSizing option set. I was wondering how I could set the initial
position and size of the dialog.. Also when the user closes the dialog I
want to save the size & position to restore it the next time it pops up. A
maximize button in the caption would be the end (why is it left out???)

Regards,

Koen

 

Re:set initial size and position for OpenDialog and SaveDialog


Quote
In article <3e822...@newsgroups.borland.com>, Koen Verbeeck wrote:
> I use the standard TOpenDialog and TSaveDialog D5 components with
> the ofEnableSizing option set. I was wondering how I could set the initial
> position and size of the dialog.. Also when the user closes the dialog I
> want to save the size & position to restore it the next time it pops up. A
> maximize button in the caption would be the end (why is it left out???)

Ask Microsoft, these are Windows common dialogs.

You can use the dialogs OnShow event to move it, with a bit of trickery. To
get the final position use the OnCanClose event.

<quote source="http://codecentral.borland.com" id="19374" line="29102">

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.

</quote>

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Other Threads