开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜