要将一个子FORM平铺在主form上的panel中,怎么办?(50分)

  • 主题发起人 主题发起人 del520
  • 开始时间 开始时间
D

del520

Unregistered / Unconfirmed
GUEST, unregistred user!
老式的程序在点击某个按钮之后就又弹出一个对话框(form),感觉有些土气,现在我同
样是有许多的子form,但我想当我点击工具栏或是菜单后将相对应的form去掉周边后平铺在
主form中,怎么办?
注:我的主form除掉菜单,工具栏,栏态栏后其它内容就是一个panel!
 
panel.docksite:=true;
 
Form.有一个入圬函数,你同时要把这个FORM的拖动该成DOCK模式,下面的哪个属性该成
AUTO -----,不好意思我在网吧,不能讲详细点
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ToolWin, ImgList, ExtCtrls, Menus, StdCtrls;

type
TForm1 = class(TForm)
ControlBar1: TControlBar;
ImageList1: TImageList;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
MainMenu1: TMainMenu;
File1: TMenuItem;
New1: TMenuItem;
Open1: TMenuItem;
Save1: TMenuItem;
N1: TMenuItem;
Exit1: TMenuItem;
Edit1: TMenuItem;
Copy1: TMenuItem;
Cut1: TMenuItem;
Paste1: TMenuItem;
View1: TMenuItem;
MnuTestWindow: TMenuItem;
Panel: TPanel;
procedure PanelGetSiteInfo(Sender: TObject; DockClient: TControl;
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
procedure MnuTestWindowClick(Sender: TObject);
procedure PanelDockOver(Sender: TObject; Source: TDragDockObject;
X, Y: Integer; State: TDragState; var Accept: Boolean);
procedure ControlBar1DockDrop(Sender: TObject; Source: TDragDockObject;
X, Y: Integer);
procedure ControlBar1GetSiteInfo(Sender: TObject; DockClient: TControl;
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
procedure FormDockDrop(Sender: TObject; Source: TDragDockObject; X,
Y: Integer);
procedure FormGetSiteInfo(Sender: TObject; DockClient: TControl;
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.PanelGetSiteInfo(Sender: TObject;
DockClient: TControl; var InfluenceRect: TRect; MousePos: TPoint;
var CanDock: Boolean);
begin
CanDock := DockClient.Tag = 2;
end;

procedure TForm1.PanelDockOver(Sender: TObject;
Source: TDragDockObject; X, Y: Integer; State: TDragState;
var Accept: Boolean);
var
ARect: TRect;
begin
Accept := Source.Control.Tag = 2;
if Accept then
begin
ARect.TopLeft := Panel.ClientToScreen(Point(0, 0));
ARect.BottomRight := Panel.ClientToScreen(
Point(Self.ClientWidth div 3, Panel.Height));
Source.DockRect := ARect;
end;
end;

procedure TForm1.MnuTestWindowClick(Sender: TObject);
begin
FrmTest.Show;
if FrmTest.HostDockSite <> nil then
FrmTest.Width := ClientWidth div 3;
end;

procedure TForm1.FormGetSiteInfo(Sender: TObject; DockClient: TControl;
var InfluenceRect: TRect; MousePos: TPoint; var CanDock: Boolean);
begin
CanDock := DockClient.Tag = 1;
end;

procedure TForm1.FormDockDrop(Sender: TObject; Source: TDragDockObject; X,
Y: Integer);
begin
Source.Control.Align := alBottom;
end;

procedure TForm1.ControlBar1GetSiteInfo(Sender: TObject;
DockClient: TControl; var InfluenceRect: TRect; MousePos: TPoint;
var CanDock: Boolean);
begin
CanDock := DockClient.Tag = 1;
end;

procedure TForm1.ControlBar1DockDrop(Sender: TObject;
Source: TDragDockObject; X, Y: Integer);
begin
Source.Control.Align := alTop;
end;

end.
 
动态创建这个窗体,并把他的Parent设成你的Panel,再Show
 
呵呵,我自个试出来了,不过还是感谢大家的帮助。:)
这样用即可:

form2.parent:=mainform.panel1;
form2.show;
 
后退
顶部