2

是否可以打开 TOpenDialog、TSaveDialog 并将焦点设置为文件列表视图而不是文件名编辑框?

非常感谢

问候

4

1 回答 1

4

您可以将焦点放在您喜欢的控件上,但是当您这样做时对话框应该准备好了。'OnShow' 活动还为时过早。例如,您可以使用“OnFolderChange”事件和一个标志,以便在每次更改文件夹时不更改焦点:

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;
于 2011-04-04T12:24:59.053 回答