【发布时间】:2013-02-06 12:25:36
【问题描述】:
当我尝试设置在运行时创建的 BitBtn 的 Parent 属性时,我在编译时遇到了一个奇怪的错误。在 Win7 64bit 上使用 Delphi 7。
[错误] unitMainForm.pas(70):不兼容的类型:'TWidgetControl' 和 'TMainForm'
我正在像这样在运行时创建 BitBtn:
newButton := TBitBtn.Create(Self);
newButton.Parent := Self;
这里的“Self”是表单,命名为“MainForm”。 无论我为父母做什么,我都会得到这个。我试过把当前的Form、ScrollBox、Panel。如果我尝试创建 SpeedButton,也会发生同样的情况。 问题是,当我使用 TButtons 甚至 TImages 时,我的代码按预期工作,但不使用 TBitBtns 或 TSpeedButtons。 TButtons 和 TImages 接受 Form 作为其父级,并按预期显示。 有任何想法吗? 如果有帮助,我可以根据要求提供整个代码的示例。
【问题讨论】: