首页  编辑  

打开对话框的列表风格

Tags: /超级猛料/VCL/Common.Dialog.通用对话框和控件/   Date Created:

如何让打开对话框强制使用Detial的风格?

procedure TForm1 . OpenDialog1FolderChange ( Sender : TObject );

var

 H , H2 : THandle ;

begin

 H := FindWindowEx ( GetParent ( OpenDialog1 . Handle ), 0 ,

   PChar ( 'SHELLDLL_DefView' ), nil );

 H2 := FindWindowEx ( H , 0 , PChar ( 'SysListView32' ), nil );

  if ( H <> 0 ) and ( H2 <> 0 ) then

  begin

   SendMessage ( H , WM_COMMAND , $702C , 0 );

   Windows . SetFocus ( H2 );

   PostMessage ( H2 , WM_KEYDOWN , VK_SPACE , 0 );

  end ;

end ;

---------------------------------------

procedure TForm1 . OpenDialog1Show ( Sender : TObject );

begin

 PostMessage ( GetParent ( OpenDialog1 . Handle ), WM_COMMAND , $A004 , 0 );

end ;

---------------------------------------

private

   { Private declarations }

   procedure WMUser(var msg: TMessage); message WM_USER+1;

 public

   { Public declarations }

 end;

var

 Form1: TForm1;

implementation

{$R *.dfm}

const

 FCIDM_SHVIEW_LARGEICON  = 28713;

 FCIDM_SHVIEW_SMALLICON  = 28714;

 FCIDM_SHVIEW_LIST       = 28715;

 FCIDM_SHVIEW_REPORT     = 28716;

 FCIDM_SHVIEW_THUMBNAIL  = 28717; //    XP only

 FCIDM_SHVIEW_TILE       = 28718; //    XP

procedure TForm1.WMUser(var msg: TMessage);

var

Dlg: HWND;

Ctrl: HWND;

begin

 Dlg := msg.WParam;

 Ctrl := FindWindowEx(Dlg, 0, PChar('SHELLDLL_DefView'), nil);

 if Ctrl <> 0 then

 begin

   SendMessage(Ctrl, WM_COMMAND, FCIDM_SHVIEW_THUMBNAIL, 0 )

 end;

end;

procedure TForm1.OpenDialog1Show(Sender: TObject);

var

 Dlg: HWND;

begin

 Dlg := GetParent((Sender as TOpenDialog).Handle);

 PostMessage(Handle, WM_USER+1, Dlg, 0);

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

 if OpenDialog1.Execute then

 begin

 end;

end;