Delphi 7, Error setting form as parent of BitBtn
I am getting a weird compile time error when I try to set the Parent property of BitBtn generated at runtime. Using Delphi 7 on Win7 64bit.
[Error] unitMainForm.pas (70): Incompatible types: 'TWidgetControl' and 'TMainForm'
I am creating BitBtn at runtime like this:
newButton := TBitBtn.Create(Self);
newButton.Parent := Self;
"I" here is a form called "MainForm". I get this no matter what I put for Parent. I tried to put the current form, ScrollBox, Panel. The same thing happens if I try to create a SpeedButton. The point is, my code works as expected when I use TButtons and even TImages, but not TBitBtns or TSpeedButtons. TButtons and TImages take the form as their parent and display as expected. Any ideas? If it helps, I can provide a sample of all the code upon request.
source to share
You are mixing CLX and VCL. Your button is CLX TBitBtn
, but your form is a VCL form.
I don't know if you want your application to be a VCL or CLX application, but depending on what it is, you need all parts of your application to come from the same structure.
I am assuming you want a VCL application. And somehow you used QButtons
, a CLX block, not Buttons
a VCL block. And that's why you get the CLX version TBitBtn
.
So, assuming I understand correctly, just change QButtons
to Buttons
and your code will compile.
source to share