unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls;type TForm1 = class(TForm) Panel2: TPanel; Panel1: TPanel; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject); begin panel1.ManualDock(panel2); end;end. // object Form1: TForm1 Left = 192 Top = 133 Width = 696 Height = 480 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Panel2: TPanel Left = 152 Top = 88 Width = 457 Height = 297 Caption = 'Panel2' DockSite = True TabOrder = 0 object Panel1: TPanel Left = 40 Top = 24 Width = 185 Height = 41 Caption = 'Panel1' DragKind = dkDock DragMode = dmAutomatic TabOrder = 0 end end end
没有测试过,你只管试试看。思路如下: exstyle=GetWindowLong(MyPanel.Handle, GWL_EXSTYLE); exstyle=exstyle or WS_EX_WINDOWEDGE or WS_EX_CAPTION or WS_EX_TOOLWINDOW; SetWindowLong(MyPanel.Handle, GWL_EXSTYLE, exstyle);具体的可以查看CreateWindowEx,SetWindowLong,GetWindowLong的Windows API帮助。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;type
TForm1 = class(TForm)
Panel2: TPanel;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
panel1.ManualDock(panel2);
end;end.
//
object Form1: TForm1
Left = 192
Top = 133
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Panel2: TPanel
Left = 152
Top = 88
Width = 457
Height = 297
Caption = 'Panel2'
DockSite = True
TabOrder = 0
object Panel1: TPanel
Left = 40
Top = 24
Width = 185
Height = 41
Caption = 'Panel1'
DragKind = dkDock
DragMode = dmAutomatic
TabOrder = 0
end
end
end
exstyle=GetWindowLong(MyPanel.Handle, GWL_EXSTYLE);
exstyle=exstyle or WS_EX_WINDOWEDGE or WS_EX_CAPTION or WS_EX_TOOLWINDOW;
SetWindowLong(MyPanel.Handle, GWL_EXSTYLE, exstyle);具体的可以查看CreateWindowEx,SetWindowLong,GetWindowLong的Windows API帮助。