TControl.WMLButtonUp的inherited的作用——是为了给子类控件新的处理消息的机会

意外注意到这个小细节:

procedure TControl.WMLButtonUp(var Message: TWMLButtonUp);
begin
inherited; // 注意,如果是直接点击Form1,会执行TCustomForm.DefaultHandler(var Message);相当于给子类控件提供了新的处理消息的机会
if csCaptureMouse in ControlStyle then MouseCapture := False;
if csClicked in ControlState then
begin
Exclude(FControlState, csClicked);
if PtInRect(ClientRect, SmallPointToPoint(Message.Pos)) then
Click;
end;
DoMouseUp(Message, mbLeft);
end;

够阴险的啊,为什么要这样做呢?是为了提前把子类的一切充分融入到VCL官方框架中?

上一篇:Exchange 2010 实用小技巧


下一篇:GEF的MVC体系结构