utils.pas

来自「观察者模式delphi实例实现,同时注意软件的设计」· PAS 代码 · 共 44 行

PAS
44
字号
unit utils;

interface

uses
    Windows, Messages, SysUtils, Graphics, Forms, Dialogs, Controls, classes
    , inifiles, mmsystem;

procedure ShowFormAsChild(var AForm: TForm; AFormClass: TClass;
                            AParent: TWinControl; AlignClient:Boolean = True);

implementation

{******************************************************************************}
procedure ShowFormAsChild(var AForm: TForm; AFormClass: TClass;
                            AParent: TWinControl; AlignClient:Boolean = True);
var
    acW,acH:Integer;
    i:Integer;
begin
    if not Assigned(AForm) then
        Application.CreateForm(TComponentClass(AFormClass), AForm);
    for i := 0 to AParent.ControlCount -1 do
    begin
        if AParent.Controls[i] is TForm then
            TForm(AParent.Controls[i]).Hide;
    end;
    AForm.Parent        := AParent;
    AForm.Left          := 0;
    AForm.Top           := 0;
    if AlignClient then
        AForm.Align := alClient;
    acW := AForm.ClientWidth;
    acH := AForm.ClientHeight;
    AForm.BorderStyle   := bsNone;
    AForm.Width         := acW;
    AForm.Height        := acH;
    AForm.BringToFront;
    AForm.Show;
end;


end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?