I am walking a form’s control list and when I find a TPicture I want to change a property (image, but anything will do for an example).
How do I code that? It seems like TPciture and TControl are not compatible. Can I cast somehow?
Update:
when I add this code
for i:= 0 to Pred(designerForm.ControlCount) do
if designerForm.Controls[i] is TPicture then
MessageDlg('Picture : ' + designerForm.Controls[i].name,
mtInformation, [mbOK], 0);
where designerForm is TForm, I go from zero to two errors in D7
[Error] PictureInspEditor.pas(121): Incompatible types: 'TPicture' and 'TControl'
[Fatal Error] E_logger.dpr(22): Could not compile used unit 'PictureInspEditor.pas'
Are you sure when you say
TPicturemaybe do you really want to sayTImage?, anyway in any case first you must check if the current control is of the class which you want evaluateTImage(in this case) then you can cast in this wayTImage(Controls[i])check this sample for a TImage
UPDATE
you can’t compare the
TPictureclass against theTControlusing theis operatorbecause the type of theTPictureis unrelated to theTControl.from the Embarcadero documentation