procedure TForm1.FormCreate(Sender: TObject);
begin
  if (csClickEvents in Button1.ControlStyle) then
    Button1.ControlStyle:=Button1.ControlStyle-[csClickEvents];
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  label1.Caption:=label1.Caption+ 'hello';
end;这样应该可以在消息处理的时候忽略click函数了,可是结果button1click还是执行了,请教为 什么?

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      exit;
    end; 
      

  2.   

    我就是想看看从消息上怎么控制,要是你这样的话我还不如onclick=nil;
      

  3.   

    是DELPHI的自定义消息让它响应了,代码:procedure TButton.CNCommand(var Message: TWMCommand);
    begin
      if Message.NotifyCode = BN_CLICKED then Click;
    end;在TControl中确实没让他响应,取作用的代码:procedure TControl.WMLButtonDown(var Message: TWMLButtonDown);
    begin
      SendCancelMode(Self);
      inherited;
      if csCaptureMouse in ControlStyle then MouseCapture := True; 
      if csClickEvents in ControlStyle then Include(FControlState, csClicked);
      DoMouseDown(Message, mbLeft, []);
    end;procedure TControl.WMLButtonUp(var Message: TWMLButtonUp);
    begin
      inherited;
      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;