INI/Reg 簡単アクセスコンポ RegMng 本田勝彦さん INIで使用する例 RegManager1.RegType := rtIni; (fTop, fLeft, fHeight, fWidth: Integer; はなくても出来ます 本田さんの例のように直に読み書きしても良いです RegManager1['Form1Width'].AsInteger := Form1.Width;) private { Private 宣言 } fTop, fLeft, fHeight, fWidth: Integer; fMaxForm : Boolean; //フラグ public { Public 宣言 } // フォームの最大化判定 procedure WMSysCommand(var Msg:TWMSysCommand);message WM_SYSCOMMAND; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.WMSysCommand(var Msg: TWMSysCommand); begin inherited; case (Msg.CmdType and $FFFFFFF0) of SC_MAXIMIZE : fMaxForm := True; // 最大化された SC_RESTORE : fMaxForm := False; // 元のサイズに戻った end; end; procedure TForm1.FormCreate(Sender: TObject); begin RegManager1.RegType := rtIni; RegManager1.IniFileName := ChangeFileExt(Application.ExeName, '.ini'); fTop := RegManager1['fTop'].AsInteger; fLeft := RegManager1['fLeft'].AsInteger; fHeight := RegManager1['fHeight'].AsInteger; fWidth := RegManager1['fWidth'].AsInteger; fMaxForm := RegManager1['fMaxForm'].AsBoolean; if fMaxForm then begin //デフォールトの位置大きさに設定 Top := 16; Left := 16; Height := 580; Width := 780; end else begin //通常のフォームサイズ位置の復帰 Top := fTop; Left := fLeft; Height := fHeight; Width := fWidth; end; end; procedure TForm1.FormShow(Sender: TObject); begin //最大化でフォームを表示させる if fMaxForm then begin Form1.WindowState := wsMaximized; end; end; procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin RegManager1['fTop'].AsInteger := Top; RegManager1['fLeft'].AsInteger := Left; RegManager1['fHeight'].AsInteger := Height; RegManager1['fWidth'].AsInteger := Width; RegManager1['fMaxForm'].AsBoolean := fMaxForm; end; |