为何用此方法捕获不到Button1点击确定事件。
procedure Tform1.ApplicationEvents1Message(var Msg: tagMSG;
 var Handled: Boolean);
begin
 case Msg.message of
   WM_COMMAND:
    if (Msg.lParam = Button1.Handle) and (HIWORD(Msg.wParam) = BN_CLICKED) then
    begin
      ShowMessage('lile');
    end;
 end;
end; 
 

解决方案 »

  1.   

    button click 引發的應該不是 WM_COMMAND;
      

  2.   

    我重载了WndProc就可以捕获button1 onclick事件。
    procedure Tform1.WndProc(var Msg: TMessage);
    begin
     inherited;
     case Msg.Msg of
      WM_COMMAND:
       if (Msg.lParam = Button1.Handle) and (HIWORD(Msg.wParam) = BN_CLICKED) then
       begin
         ShowMessage('lile');
       end;end;
    end; 所以说问题不是出在消息上,根据书本介绍ApplicationEvents1Message只能捕获到进队的消息,点击按钮事件本身应该就是属于进队消息啊!