• WriteformState()ReadformState()


    uses IniFiles;//引用IniFiles
     
    {写入信息到ini文件 }
    //WriteformState('Config.ini','MainForm',Form1)
    procedure WriteformState(fileName:string;section:string;form:TForm);
    var  INIFILE: TIniFile; 
    begin
        INIFILE:=TIniFile.Create(ExtractFilePath(Application.ExeName)+fileName); 
        try
         INIFILE.WriteInteger(section,'Left',  form.Left);
         INIFILE.WriteInteger(section,'Top',   form.Top);
         INIFILE.WriteInteger(section,'Height',form.Height); 
         INIFILE.WriteInteger(section,'width', form.Width); 
        Finally  
         INIFILE.Free; 
        end;  
    end;  


    {从Ini读取信息并赋值}
    //ReadformState('Config.ini','MainForm',Form1)
    procedure ReadformState(fileName:string;section:string;form:TForm);
    var 
     INIFILE: TIniFile; 
     frm1Left,frm1Top:integer;  
    begin
      form.Position:=poDesigned;
      //FORM1 处于屏幕中心点时的left Top的值 用于第1次运行本程序时程序出现 在屏幕中心 
      frm1Left:=(Screen.Width-FORM.Width) div 2; 
      frm1Top :=(Screen.Height-FORM.Height) div 2; 
      INIFILE :=TIniFile.Create(ExtractFilePath(Application.ExeName)+fileName); 
        try  
             form.Left:= INIFILE.ReadInteger(section,'Left',  frm1Left); 
              form.Top:= INIFILE.ReadInteger(section,'Top',   frm1Top); 
           form.Height:= INIFILE.ReadInteger(section,'Height',form.Height); 
            form.Width:= INIFILE.ReadInteger(section,'Width', form.Width); 
        Finally 
          INIFILE.Free; 
        end;  
    end; 
     




  • 相关阅读:
    今天学习的数组不是很懂
    今天的复习内容
    这是今天的作业
    总结,错误反思
    php 文件读取
    call_user_func函数
    plsql中调试函数 转
    oracle数据库中函数的递归调用
    关闭PdfReader右侧工具栏的方法
    Dev TreeList基本用法
  • 原文地址:https://www.cnblogs.com/xe2011/p/2609332.html
Copyright © 2020-2023  润新知