• 款式修改窗口,开发调整过窗口格局保存功能,关了窗口重新打开还是按关闭前的格局.


    1.
    如果允许用户在运行时移动控件和调整控件大小,你必须确保在窗体关闭时保存控件的位置,窗体创建/加载时恢复每个控件的位置。以下是如何在INI文件中存储的每个窗体上的控件的左,上,宽度和高度属性。

    接下来的两个程序TFrmStyleProp.WriteControlPlacement;
    var和TFrmStyleProp.ReadControlPlacement;用Delphi的ini文件来存储和恢复窗体上每一个控制的位置属性:
    //款式修改窗口格局 BN0158
    uiuujhbfggchchhchjhcjhjchj

    //写窗口的控制放置位置
    procedure TFrmStyleProp.WriteControlPlacement;
    var
    iniFile : TIniFile;
    idx : integer;
    ctrl : TControl;
    begin
    iniFile := TIniFile.Create(ChangeFileExt(Application.ExeName,'-prop.ini')) ;
    try
    for idx := 0 to -1 + Self.ComponentCount do
    begin
    if Components[idx] is TRzSizePanel then
    begin
    ctrl := TControl(Components[idx]) ;
    iniFile.WriteInteger(ctrl.Name,'Top',ctrl.Top) ;
    iniFile.WriteInteger(ctrl.Name,'Left',ctrl.Left) ;
    iniFile.WriteInteger(ctrl.Name,'Width',ctrl.Width) ;
    iniFile.WriteInteger(ctrl.Name,'Height',ctrl.Height) ;
    end;
    end;
    finally
    FreeAndNil(iniFile) ;
    end;
    end;

    //读控制窗口的位置
    procedure TFrmStyleProp.ReadControlPlacement;
    var
    iniFile : TIniFile;
    idx : integer;
    ctrl : TControl;
    begin
    iniFile := TIniFile.Create(ChangeFileExt(Application.ExeName,'-prop.ini')) ;
    try
    for idx := 0 to -1 + Self.ComponentCount do
    begin
    if Components[idx] is TRzSizePanel then
    begin
    ctrl := TControl(Components[idx]) ;
    ctrl.Top := iniFile.ReadInteger(ctrl.Name,'Top',ctrl.Top) ;
    ctrl.Left := iniFile.ReadInteger(ctrl.Name,'Left',ctrl.Left) ;
    ctrl.Width := iniFile.ReadInteger(ctrl.Name,'Width',ctrl.Width) ;
    ctrl.Height := iniFile.ReadInteger(ctrl.Name,'Height',ctrl.Height) ;
    end;
    end;
    finally
    FreeAndNil(iniFile) ;
    end;
    end; (*ReadControlPlacement*)

    2.procedure ReadControlPlacement;
    procedure WriteControlPlacement;


    3.procedure TFrmStyleProp.act_CloseStyleExecute(Sender: TObject);
    begin
    .........
    WriteControlPlacement
    end;


    4.//调用

    在窗口的FormShow事件处理函数中调用ReadControlPlacement;
    procedure TFrmStyleProp.FormShow(Sender: TObject);
    begin
    ReadControlPlacement;
    end;

    在窗口的FormClose事件处理函数中调用WriteControlPlacement;

    procedure TFrmStyleProp.FormClose(Sender: TObject;
    var Action: TCloseAction);
    begin
    WriteControlPlacement;
    Action := caFree;
    end;


    5.
    uses
    ..........
    ..........
    ..........
    IniFiles;

  • 相关阅读:
    [转]IIS 6.0中配置HTTP Gzip压缩
    SmartPhone下解决rm、rmvb等格式电影播放的方案(参考意见)
    提取文件夹下所有文件,按类型进行提取
    重学JSP—设置CATALINA_HOME环境变量
    android学习笔记
    用myeclipse配置hibernate
    Java 回调函数 转自:http://blog.sina.com.cn/s/blog_48cf38890100go6x.html
    fastadmin单独控制编辑、删除按钮的展示和隐藏
    fastadmin导出图片
    php计算坐标距离
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/8819839.html
Copyright © 2020-2023  润新知