delphi 实现窗口记住关闭时的坐标位置


本文整理自网络,侵删。

 

var
  ini: TIniFile;

 

 

procedure TForm1.FormCreate(Sender: TObject);
begin
ini := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Config.ini');  {ini 对象建立需要文件路径参数, 如果缺少路径会默认Windows目录}

end;

 

 

procedure TForm1.Timer1Timer(Sender: TObject);
begin
try
try
if ini.ReadString('窗口坐标','X','')<>'' then
begin
form1.Left:=strtoint(ini.ReadString('窗口坐标','X',''));
end;

if ini.ReadString('窗口坐标','Y','')<>'' then
begin
form1.top:=strtoint(ini.ReadString('窗口坐标','Y',''));
end;
except
end;
finally
end;
timer1.Enabled:=false;
end;

 

 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
  hhh:HWnd;//窗口句柄
  Rect:TRect;
begin
hhh:=findwindow(nil,'桌面名人名言');
GetWindowRect(hhh,Rect);
FX:=Rect.Left;
FY:=Rect.top;
ini.WriteString('窗口坐标','X',inttostr(FX));
ini.WriteString('窗口坐标','y',inttostr(FY));

end;

相关阅读 >>

Delphi rest客户端程序

Delphi textfile utf8编码读写

Delphi datetimepicker控件日期格式

Delphi 为数字补充前缀0

Delphi html转义

Delphi 如何从html格式的字符串中提取纯文本?

Delphi 提高unigui开发效率的两个方法

Delphi 如何将颜色值转换为html格式?

orangeui作者开源作品

Delphi 如何将颜色值转换为灰度颜色值?

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...