如何捕获鼠标在窗体标题栏区域的事件!

解决方案 »

  1.   

    重新捕获WM_NcHitTest消息!
    ....
    public
      procedure WmNcHitTest(var Msg:TMessage);message WM_NCHITTEST;
    ....
    procedure TForm1.WmNcHitTest(var Msg:TMessage);message WM_NCHITTEST;
    begin
    end;
      

  2.   

    过程定义:
    捕捉上FORM的WM_NCHITTEST消息
    public
      procedure CreateParams(Var Params: TCreateParams); Override;
      procedure DragForm(Var Msg: TWMNCHITTEST);Message WH_NCHITTEST;procedure TForm1.CreateParams(Var Params: TCreateParams);
    begin
      //设置Form的风格
      Inherited CreateParams(Params);
      Params.Style := WS_THICKFRAME or WS_POPUP or WS_BORDER;
    end;
    procedure TForm1.DragForm(Var Msg: TWMNCHITTEST);
    begin
      //使鼠标可以拖动Form本身移动
      Msg.Result := HTCAPTION;
    end;
      

  3.   

    procedure TForm1.WmNcHitTest(var Msg:TMessage);message WM_NCHITTEST;
    begin
      if Result=htCation then
        //SomeCodeImplementTheFunctionYouWant;
    end;
      

  4.   

    各位讲的是检测鼠标在WM_NCHITTEST区的事件.不是我想要的啊。
    写个伪代码表达我的问题 : if 鼠标在 标题栏上按下 then showmessage('you click htcaption!').
      

  5.   

    public
      procedure WmNcHitTest(var Msg:TMessage);message WM_NCHITTEST;procedure TForm1.WmNcHitTest(var Msg:TMessage);
    begin
      inherited;
      if Result=htCation then showmessage('you click htcaption!')
    end;