control '' has no parent window
请兄弟们帮看看!写了一个简单的组合组件,想把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;