想做一个简单的复合组件,像下图所示:控件继承自TCustomPanel,上面放两个Panel,上部的Panel靠上对齐,下部的Panel充满客户区。要控制在设计期向控件添加子控件时不能添加到上部的Panel2,只能添加到下部的Panel3中。就像向PageControl添加控件时只能添加到其中的TabSheet一样。
看了PageControl的源码,没有找到那里实现的。
欢迎大家讨论,可用分非常多,回头可以另开贴添加。呵呵
看了PageControl的源码,没有找到那里实现的。
欢迎大家讨论,可用分非常多,回头可以另开贴添加。呵呵
解决方案 »
- Delphi TADOQuery带参数查询出错
- delphi中dbgrid的修改问题
- 为什么这样的鼠标钩子只能对调用窗口有用?(附源码)
- 怎样使程序的界面可以随操作系统的分辨率调整而调整.
- 安装delphi5出现的问题:请大虾指点,急!
- createoleobject在线等待!急!
- 小弟真的没分了,肯求大哥大姐进来帮帮小弟,关于软件网络版发布问题。
- 在Edit中输入用逗号隔开的字符,最后一个也有逗号,怎么判断输入格式是否正确?
- 出现一个错误不知如何解决
- 高分相送--------------------------高人帮看这个idSMTP 发送是否有问题?
- 关开汇编语言里寄存器的疑问
- 自动升级被360拦了,求解决思路?
unit Custompanel1;interfaceuses
SysUtils, Classes, Controls, ExtCtrls;type
TCustompanel1 = class(TPanel)
private
FP1: TCustomPanel;
FP2: TCustomPanel;
protected
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
function GetChildParent: TComponent; override;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
published
property P1: TCustomPanel read FP1;
property P2: TCustomPanel read FP2;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Samples', [TCustompanel1]);
end;{ TCustompanel1 }constructor TCustompanel1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FP1 := TPanel.Create(Self);
FP2 := TPanel.Create(Self);
FP1.Parent := Self;
FP2.Parent := Self;
FP1.Align := alTop;
FP2.Align := alClient;
Self.ControlStyle := Self.ControlStyle - [csAcceptsControls];
FP1.ControlStyle := FP1.ControlStyle - [csAcceptsControls];
end;function TCustompanel1.GetChildParent: TComponent;
begin
Result := FP2;
end;procedure TCustompanel1.GetChildren(Proc: TGetChildProc; Root: TComponent);
var
I: Integer;
Control: TControl;
begin
for I := 0 to FP2.ControlCount - 1 do
begin
Control := FP2.Controls[I];
if Control.Owner = Root then Proc(Control);
end;
end;end.
FP1 := TPanel.Create(AOwner);
FP1.Name := 'MyChildPanel1';
FP2 := TPanel.Create(AOwner);
FP2.Name := 'MyChildPanel2';
在Torry中搜Firebird