码迷,mamicode.com
首页 > 其他好文 > 详细

追踪CM_CONTROLCHANGE消息的产生和执行过程,可以较好的领会VCL的思想(就是到处通知,但耦合性很弱)

时间:2015-08-25 21:17:42      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

追踪CM_CONTROLCHANGE消息的流向,可以较好的

测试代码:

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;

追踪CM_CONTROLCHANGE消息的产生和执行过程,可以较好的领会VCL的思想(就是到处通知,但耦合性很弱)

标签:

原文地址:http://www.cnblogs.com/findumars/p/4758446.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!