像Word那样,每个子窗体都是最大化的,已经创建的子窗体不再创建,而是把它放到前面
我用的方法
主窗体代码:
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ToolWin, Menus, WinSkinData;type
  TMainForm = class(TForm)
    SkinData1: TSkinData;
    ToolBar1: TToolBar;
    ToolButton2: TToolButton;
    ToolButton1: TToolButton;
    ToolButton3: TToolButton;
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  MainForm: TMainForm;implementation{$R *.dfm}
uses Unit2, Unit3;
procedure TMainForm.ToolButton1Click(Sender: TObject);
begin
  if not assigned(InputForm) then
    begin
      InputForm:=TInputForm.Create(self);
      InputForm.Show;
    end else
      InputForm.Width:=MainForm.ClientWidth;
      InputForm.Height:=MainForm.ClientHeight;
      InputForm.Top:=0;
      InputForm.Left:=0;
      InputForm.WindowState:=wsMaximized;
      InputForm.BringToFront;
end;procedure TMainForm.ToolButton2Click(Sender: TObject);
begin
  if not assigned(ViewForm) then
    begin
      ViewForm:=TViewForm.Create(self);
      VIewForm.Show;
    end else
      ViewForm.Width:=MainForm.ClientWidth;
      ViewForm.Height:=MainForm.ClientHeight;
      ViewForm.Top:=0;
      ViewForm.Left:=0;
      ViewForm.WindowState:=wsMaximized;
      ViewForm.BringToFront;
end;end.
子窗体代码:
unit Unit2;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ToolWin, ComCtrls, Buttons;type
  TInputForm = class(TForm)
    RichEdit1: TRichEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn4: TBitBtn;
    Edit1: TEdit;
    Label1: TLabel;
    BitBtn5: TBitBtn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure CreateParams(var Params: TCreateParams); override;
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  InputForm: TInputForm;implementation{$R *.dfm}Procedure  TInputForm.CreateParams( var Params : tCreateParams );
Begin
  Inherited CreateParams( Params );
  Params.Style := Params.Style and (not WS_CAPTION);
End;procedure TInputForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Self:=nil;
  Action:=caFree;
end;end.只有这样才能隐藏掉该死的标题栏,但是问题是切换时总有闪烁一下标题栏还有一个问题,我用了vclskin后,如果主窗体有菜单的话,菜单旁边总是有子窗体的三个按钮,怎么去掉?谢谢!

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ComCtrls, ToolWin, Menus, WinSkinData;type
      TMainForm = class(TForm)
        SkinData1: TSkinData;
        ToolBar1: TToolBar;
        ToolButton2: TToolButton;
        ToolButton1: TToolButton;
        ToolButton3: TToolButton;
        procedure ToolButton1Click(Sender: TObject);
        procedure ToolButton2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      MainForm: TMainForm;implementation{$R *.dfm}
    uses Unit2, Unit3;
    procedure TMainForm.ToolButton1Click(Sender: TObject);
    begin
      lockwindowupdate(handle);
      if not assigned(InputForm) then
        begin
          InputForm:=TInputForm.Create(self);
          InputForm.Width:=MainForm.ClientWidth;
          InputForm.Height:=MainForm.ClientHeight;
          InputForm.Top:=0;
          InputForm.Left:=0;
          if InputForm.WindowState<>wsMaximized then InputForm.WindowState:=wsMaximized;
        end else
          begin
            InputForm.Width:=MainForm.ClientWidth;
            InputForm.Height:=MainForm.ClientHeight;
            InputForm.Top:=0;
            InputForm.Left:=0;
            if InputForm.WindowState<>wsMaximized then InputForm.WindowState:=wsMaximized;
            InputForm.setfocus;
          end;
      lockwindowupdate(0);
    end;procedure TMainForm.ToolButton2Click(Sender: TObject);
    begin
      lockwindowupdate(handle);
      if not assigned(ViewForm) then
        begin
          ViewForm:=TViewForm.Create(self);
          ViewForm.Width:=MainForm.ClientWidth;
          ViewForm.Height:=MainForm.ClientHeight;
          ViewForm.Top:=0;
          ViewForm.Left:=0;
          if ViewForm.WindowState<>wsMaximized then ViewForm.WindowState:=wsMaximized;
        end else
          begin
            ViewForm.Width:=MainForm.ClientWidth;
            ViewForm.Height:=MainForm.ClientHeight;
            ViewForm.Top:=0;
            ViewForm.Left:=0;
            if ViewForm.WindowState<>wsMaximized then ViewForm.WindowState:=wsMaximized;
            ViewForm.setfocus;
          end;
          lockwindowupdate(0);
    end;end.这样倒是不闪了,但每次点击button总是窗体要动一下,烦躁!