在程序退出时保存程序的位置(如TOP LEFT)到注册表里!在程序启动时,根据读注册表得到的数据来确定窗口的位置!

解决方案 »

  1.   

    可参考:
    var
      faceIni: TIniFile;
    begin
      faceini:=TIniFile.Create(ExtractFileDir(Application.ExeName)+'\Position.ini');
      Top:=faceIni.ReadInteger('Pos','Top','10');
      Left:=faceIni.ReadInteger('Pos','Left','10');
    end;
      

  2.   

    用这个记住窗口关闭时的位置和大小
    procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    var
      mypath : string;
    begin
      mypath := extractfilepath(application.ExeName);
      showmessage(mypath);
      with tinifile.create(mypath+'form.ini') do
      begin                               //write the form positon in '.ini' file
        writeinteger(name,'left',left);
        writeinteger(name,'top',top);
        writeinteger(name,'width',width);
        writeinteger(name,'height',height);
        free;
      end; 
    end;
    用这个读上次窗口打开的位置和大小
    procedure TForm1.FormCreate(Sender: TObject);
    var
      mypath : string;
      MyIniFile: TIniFile;
      newbmp:tbitmap;
      i,j:integer;
    begin
        mypath :=extractfilepath(application.ExeName);
        showmessage(mypath);
        myinifile:=TIniFile.Create(mypath+'form.ini');
        with myinifile do
        begin
          if readinteger(name,'left',-1)=-1 then     //if '.ini' file not exit
          begin
            left:=50;
            top:=50;
          end
          else
          begin
            left:=readinteger(name,'left',left);   //read the form initial position
            top:=readinteger(name,'top',top);
            height:=readinteger(name,'height',height);
            width:=readinteger(name,'width',width);
          end;
          free;
        end; 
    end;
      

  3.   

    同意zlw37(独孤飞) 
    补充一下,在Uses段内要加上
    uses IniFiles;