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

    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;

  • 相关阅读:
    [Memcached]操作
    [Linux-CentOS7]安装Telnet
    PAT Advanced 1093 Count PAT's (25分)
    PAT Advanced 1065 A+B and C (64bit) (20分)
    PAT Advanced 1009 Product of Polynomials (25分)
    PAT Advanced 1008 Elevator (20分)
    PAT Advanced 1006 Sign In and Sign Out (25分)
    PAT Advanced 1002 A+B for Polynomials (25分)
    半年分布式处理回顾&机器学习(一)——线性回归
    PAT Advanced 1147 Heaps (30分)
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/8819839.html
Copyright © 2011-2022 走看看