Author: Jonas Bilinkevicius
Is there a way to programmatically change the size of the TOpenDialog window so 
that more files will be shown? In Win98, the user can drag the dialog window to 
increase its size. Can the window size be increased under program control?
Answer:
The OnShow event seems to be a bit too early to do it. It has to be delayed a bit. 
Like this:
1   type
2     TForm1 = class(TForm)
3       Button1: TButton;
4       OpenDialog1: TOpenDialog;
5       procedure Button1Click(Sender: TObject);
6       procedure OpenDialog1Show(Sender: TObject);
7     private
8       { Private declarations }
9       procedure MoveDialog(var Msg: TMessage); message WM_USER;
10    public
11      { Public declarations }
12    end;
13  
14  var
15    Form1: TForm1;
16  
17  implementation
18  
19  {$R *.DFM}
20  
21  procedure TForm1.Button1Click(Sender: TObject);
22  begin
23    if OpenDialog1.Execute then
24      Caption := OpenDialog1.FileName;
25  end;
26  
27  procedure TForm1.OpenDialog1Show(Sender: TObject);
28  begin
29    PostMessage(Self.Handle, WM_USER, 0, 0);
30  end;
31  
32  function GetDesktopWorkArea: TRect;
33  begin
34    if not SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0) then
35      Result := Rect(0, 0, Screen.Width, Screen.Height);
36  end;
37  
38  procedure TForm1.MoveDialog(var Msg: TMessage);
39  var
40    rec: TRect;
41    wh: HWND;
42    l, t, r, b: Integer;
43  begin
44    wh := Windows.GetParent(OpenDialog1.Handle);
45    {if GetWindowRect(wh, rec) then}
46    if IsWindow(wh) then
47    begin
48      rec := GetDesktopWorkArea;
49      l := rec.Left;
50      t := rec.Top;
51      r := rec.Right;
52      b := rec.Bottom;
53      MoveWindow(wh, l, t, r, b, True);
54    end;
55  end;
			
           |