delphi 实现窗口记住关闭时的坐标位置  
官方Delphi 学习QQ群: 682628230(三千人)
频道

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;


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.074580192565918 seconds