您现在的位置:首页 >> VCL >> VCL >> 内容

Delphi中TRzPageControl实现多窗口的融合窗口

时间:2011/9/3 16:23:35 点击:

  核心提示:典型的融合窗口,比如Maxthon浏览器,浏览多个网页非常方便;微软眼见融合窗口众望所归,在IE7版本也引入了融合窗口技术,但微软的IE既耗内存又容易崩溃。题外话不多说了。在delphi实现其实也很简...
典型的融合窗口,比如Maxthon浏览器,浏览多个网页非常方便;微软眼见融合窗口众望所归,在IE7版本也引入了融合窗口技术,但微软的IE既耗内存又容易崩溃。题外话不多说了。在delphi实现其实也很简单:

procedure ShowDockForm(FormClass: TFormClass; dockCtrl: TWinControl;
IsMaxed: Boolean);

procedure ShowCaption(ParentCtrl:TWinControl;ACaption:string);
begin
    if ParentCtrl is TRzTabSheet then
     TRzTabSheet(ParentCtrl).Caption := ACaption;
end;

var
i: Integer;
TabCtrl:TRzTabSheet;
Form:TForm;
begin
Screen.Cursor := crHourGlass;
try
    for i := 0 to Screen.CustomFormCount - 1 do
      if Screen.CustomForms[i] is FormClass then
      begin
        if (not (Screen.CustomForms[i]).Visible) then
          (Screen.CustomForms[i]).Visible := True;
        (Screen.CustomForms[i]).BringToFront;
        (Screen.CustomForms[i]).SetFocus;
        TabCtrl := TRzTabSheet(Screen.CustomForms[i].Parent);
        ShowCaption(TabCtrl,Screen.CustomForms[i].Caption);
        TRzPageControl(dockCtrl).ActivePageIndex := TabCtrl.PageIndex;
          exit;
      end;

    TabCtrl := TRzTabSheet.Create(dockCtrl);   //dockCtrl
    TabCtrl.PageControl := TRzPageControl(dockCtrl);
    TRzPageControl(dockCtrl).ActivePageIndex := TabCtrl.PageIndex;

    Form := FormClass.Create(TabCtrl);
    with Form do
    try
      ManualDock(TabCtrl);
      ShowCaption(TabCtrl,Caption);

      Show;
      Form.WindowState := wsMaximized;
      Form.Align := alClient;
    except
      Free;
    end;
   
finally
    Screen.Cursor := crDefault;
end;
end;


以上代码是在 Raize 5.X中的TRzPageControl 实现多窗口的融合窗口。

融合窗口也有不足之处,如果两个TForm有相同的TActionList快捷键,只有第一个窗口的快捷键有效。

作者:tintinsoft 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号