I'm getting a weird error at compilation when I try to set the Parent property of a BitBtn that's been created at runtime. Using Delphi 7 on Win7 64bit.
[Error] unitMainForm.pas(70): Incompatible types: 'TWidgetControl' and 'TMainForm'
I'm creating the BitBtn at runtime like this:
newButton := TBitBtn.Create(Self);
newButton.Parent := Self;
"Self" here being the form, named "MainForm". I'm getting this no matter what I put for a Parent. I've tried putting the current Form, ScrollBox, Panel. The same happens if I try to create a SpeedButton. The thing is, my code works as expected when I use TButtons, and even TImages, but not with TBitBtns or TSpeedButtons. TButtons and TImages accept the Form as their parent, and show up as expected. Any ideas? If it helps, I could provide a sample of the whole code, upon request.
You are mixing CLX and VCL. Your button is the CLX TBitBtn, but your form is a VCL form.
I don't know whether you want your app to be a VCL app or a CLX app, but whichever it is, you need all the parts of your app to come from the same framework.
My guess is that you want a VCL app. And somehow you have used QButtons, the CLX unit, rather than Buttons, the VCL unit. And that's why you are getting the CLX version of TBitBtn.
So, assuming I'm guessing right, simply change QButtons to Buttons and your code will compile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With