Tracking the flow of cm_controlchange messages can be better
Test code:
Procedure Tform1.button1click (Sender:tobject);
Var
Image2:timage;
Begin
Image2: = Timage.create (self);
Image2.left: = 100;
Image2.top: = 50;
Image2.Picture.LoadFromFile (' c:\pic.jpg ');
Image2.parent: = Form1;
End
Procedure Twincontrol.insertcontrol (Acontrol:tcontrol);
Begin
Acontrol.validatecontainer (self);
Perform (Cm_controllistchange, Integer (acontrol), Integer (True));
Insert (Acontrol);
If not (csreading in acontrol.componentstate) then
Begin
Acontrol.perform (cm_parentcolorchanged, 0, 0);
Acontrol.perform (cm_parentfontchanged, 0, 0);
Acontrol.perform (cm_parentshowhintchanged, 0, 0);
Acontrol.perform (cm_parentbidimodechanged, 0, 0);
If Acontrol is Twincontrol then
Begin
Acontrol.perform (cm_parentctl3dchanged, 0, 0);
Updatecontrolstate;
End Else
If handleallocated then acontrol.invalidate;
Aligncontrol (Acontrol);
End
Perform (Cm_controlchange, Integer (acontrol), Integer (True));
End
Tracking the generation and execution of Cm_controlchange messages, you can better understand the idea of VCL (that is, the information is everywhere, but the coupling is very weak)