开发者

Open / save file dialog set focus to the file list view

开发者 https://www.devze.com 2023-02-21 17:55 出处:网络
is it possible to open TOpenDialog, TSaveDialog with 开发者_StackOverflow社区focus set to the file list view instead of file name edit box ?

is it possible to open TOpenDialog, TSaveDialog with 开发者_StackOverflow社区focus set to the file list view instead of file name edit box ?

Thanks a lot

Regards


You can put the focus to the control you like but the dialog should be ready when you do that. The 'OnShow' event is early for that. You can use 'OnFolderChange' event for instance, together with a flag in order to not to change the focus every time the folder is changed:

type
  TForm1 = class(TForm)
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    procedure OpenDialog1FolderChange(Sender: TObject);
  private
    FDlgSetFocus: Boolean;

uses
  dlgs;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FDlgSetFocus := False;
  OpenDialog1.Execute;
end;

procedure TForm1.OpenDialog1FolderChange(Sender: TObject);
begin
  if not FDlgSetFocus then
    windows.SetFocus(GetDlgItem(GetParent((Sender as TOpenDialog).Handle), lst2));
  FDlgSetFocus := True;
end;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号