zoukankan      html  css  js  c++  java
  • 保存form配置信息INI

    (* 
    功能:IniFormState
    1 保存和读取 窗体的大小
    2 保存和读取 窗体在屏幕上的位置
    //让程序第1次出现在屏幕的中心点
    获取屏幕的中心点
    POSITION:poScreenCenter //不行
    *)


    //implementation
    //{$R *.dfm}
     uses IniFiles;//引用IniFiles

    /// 写入信息到ini文件  
    procedure WriteformState(section:string;fileName: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读取信息并赋值
    procedure ReadformState(section:string;fileName:string;form:TForm);
    var
     INIFILE: TIniFile;
     frm1Left,frm1Top:integer; 
    begin 
      
    //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;
     
    //调用
    //读取信息
     ReadformState('MainForm','Config.ini',Form1); 
    //写入信息 
    WriteformState('MainForm','Config.ini',Form1);
     




  • 相关阅读:
    Flash性能相关
    穿过某点绘制曲线
    oracle 动态列
    oracle 失效对象自动重新编译
    EBS 重新编译无效对象 invalid object
    oracle ebs Customer Info
    Oracle Customer Contacts Info
    Report Builder中的页码问题
    APPFND01564 ORA6502,ORA06512 in afscpcon IE 9
    EBS中发送电子邮件
  • 原文地址:https://www.cnblogs.com/xe2011/p/3876197.html
Copyright © 2011-2022 走看看