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官方框架中?

原文地址:https://www.cnblogs.com/findumars/p/4758554.html