control '' has no parent window

wlywangliyi 2006-09-09 03:17:10
请兄弟们帮看看!写了一个简单的组合组件,想把toolbar和tollbutton组合起来,安装后从面板上拖到form上时报以上的错误!程序代码如下:
constructor TScrollBoxBusinessFlow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Name :='sb1';
Width := 300;
Height := 400;
AutoScroll := True;
with TToolButton.Create(Self) do
begin
Parent := Self;
Left := 0;
Top := 0;
Caption := 'Button1';
end;

FToolBar := TToolBar.Create(Self);
with FToolBar do
begin
Name :='tb1';
Parent := Self;
Align := alTop;
Width := Self.Width;
AutoSize := True;
ShowCaptions := True;
end;
//ToolButton
with TToolButton.Create(FToolBar) do
begin
Name :='tbb1';
Parent := FToolBar;//调试发现,设置此值有问题
Caption := 'Start';
Style := tbsButton;
end;

//Image
FImageFlow := TImage.Create(Self);
With FImageFlow do
begin
Parent := Self;
Width := IMAGE_WIDTH;
Height := IMAGE_HEIGHT;
Top := 100;
Left := (Self.Width - Width - 18) div 2;

Canvas.Font.Name := '宋体';
Canvas.Font.Size := 9;
Canvas.Font.Charset := GB2312_CHARSET;
Canvas.Font.Color := clBlack;

Canvas.Brush.Color := COLOR_BASE;
Canvas.FillRect(ClientRect);
end;
FCurrentStepNo := 0;
end;
...全文
286 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
王集鹄 2006-09-10
  • 打赏
  • 举报
回复
public
procedure CreateWnd; override;
end;
//重载CreateWnd方法中..

procedure TScrollBoxBusinessFlow.CreateWnd;
begin
//...
end;
47522341 2006-09-10
  • 打赏
  • 举报
回复
将那个self换成Aowner看看
wlywangliyi 2006-09-10
  • 打赏
  • 举报
回复
兄弟果然是高人,可是不通道怎么个我的组件的paren赋值呢?
luxuewei5214 2006-09-09
  • 打赏
  • 举报
回复
给控件的parent属性赋值
MFC开发过程序所需的ModifyStyle(needDelStyle,needAddStyle,SWP_FRAMECHANGED); Sytel: WS_BORDER Creates a window that has a border. WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). Cannot be used with the WS_DLGFRAME style. WS_CHILD Creates a child window. Cannot be used with the WS_POPUP style. WS_CHILDWINDOW Same as the WS_CHILD style. WS_CLIPCHILDREN Excludes the area occupied by child windows when you draw within the parent window. Used when you create the parent window. WS_CLIPSIBLINGS Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only. WS_DISABLED Creates a window that is initially disabled. WS_DLGFRAME Creates a window with a double border but no title. WS_GROUP Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style FALSE after the first control belong to the same group. The next control with the WS_GROUP style starts the next group (that is, one group ends where the next begins). WS_HSCROLL Creates a window that has a horizontal scroll bar. WS_ICONIC Creates a window that is initially minimized. Same as the WS_MINIMIZE style. WS_MAXIMIZE Creates a window of maximum size. WS_MAXIMIZEBOX Creates a window that has a Maximize button. WS_MINIMIZE Creates a window that is initially minimized. For use with the WS_OVERLAPPED style only. WS_MINIMIZEBOX Creates a window that has a Minimize button. WS_OVERLAPPED Creates an overlapped window. An overlapped window usually has a caption a

5,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧