gpt4 book ai didi

delphi - TSaveDialog位置

转载 作者:行者123 更新时间:2023-12-01 18:05:33 24 4
gpt4 key购买 nike

TSaveDialog的默认位置是屏幕的中心。如何设置TSaveDialog窗口的位置?我想要这样的东西:

SaveDialog1.top := topValue;
SaveDialog1.left := leftValue;
if (SaveDialog1.execute(self.handle)) then begin
...
end;

最佳答案

我在这个 page 找到了这个示例,但我已将其修改为与退出 TSaveDialog 一起使用,而不是创建新类。

type
TSaveDialog = class(Dialogs.TSaveDialog)
protected
fTop: integer;
fLeft: integer;
procedure WndProc(var Message: TMessage); override;
public
property top: integer read fTop write fTop;
property left: integer read fLeft write fLeft;
end;

type
TForm1 = class(TForm)
dlgSave1: TSaveDialog;
btn1: TButton;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.dfm}
uses
CommDlg;

procedure TForm1.btn1Click(Sender: TObject);
begin
dlgSave1.left := 20;
dlgSave1.top := 100;
if dlgSave1.Execute then
// do your work here
end;

{ TMySaveDialog }

procedure TSaveDialog.WndProc(var Message: TMessage);
begin
inherited WndProc(Message);
if (Message.Msg = WM_NOTIFY) then
case (POFNotify(Message.LParam)^.hdr.code) of
CDN_INITDONE: SetWindowPos(POFNotify(Message.LParam)^.hdr.hwndFrom, 0, fLeft, fTop, 0, 0, SWP_NOSIZE);
end;
end;

关于delphi - TSaveDialog位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/657388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com