Procedure TFommain.wmnchitTest(Var M: TWMNCHitTest);
Begin
  Inherited;
  If M.Result = htclient Then
  Begin
    M.Result := HTCAPTION;
  End;
end;
  //这样能实现移动无标题窗体
Procedure TFommain.wmnchitTest(Var M: TWMNCHitTest);
Begin
    If M.Result = htclient Then
  Begin
    M.Result := HTCAPTION;
  end;
  Inherited;  //这样不能实现移动无标题窗体,为什么?
End;这两种方式,对消息的处理有何不同?

解决方案 »

  1.   

    inherited放在后面的话,就会重新计算HitTest,结果就覆盖了你的HTCAPTION了
      

  2.   

    呵呵 刚找到的 也是转贴........./**************************在窗体的OnMouseDown事件中加入下面几行代码即可If Button = mbleft Then
    begin
       ReleaseCapture;
       SendMessage(form1.Handle, WM_NCLBUTTONDOWN, HTCAPTION,0);
    end;若窗体的表面被别的控件履盖掉,则需要把上面的代码加入履盖的控件里面。版权归金晨所有,请不要转载!**************************/
      

  3.   

    重新计算HitTest
    ====================
    hittest是什么东东?
      

  4.   

    hittest是什么东东?
    -----------------------------
    The framework calls this member function for the CWnd object that contains the cursor (or the CWnd object that used the SetCapture member function to capture the mouse input) every time the mouse is moved.
      

  5.   

    One of the mouse hit-test enumerated values listed below is the Return Value of OnNcHitTest function.Mouse Enumerated Values
    HTBORDER   In the border of a window that does not have a sizing border. 
    HTBOTTOM   In the lower horizontal border of the window. 
    HTBOTTOMLEFT   In the lower-left corner of the window border. 
    HTBOTTOMRIGHT   In the lower-right corner of the window border. 
    HTCAPTION   In a title-bar area. 
    HTCLIENT   In a client area. 
    HTERROR   On the screen background or on a dividing line between windows (same as HTNOWHERE except that the DefWndProc Windows function produces a system beep to indicate an error). 
    HTGROWBOX   In a size box. 
    HTHSCROLL   In the horizontal scroll bar. 
    HTLEFT   In the left border of the window. 
    HTMAXBUTTON   In a Maximize button. 
    HTMENU   In a menu area. 
    HTMINBUTTON   In a Minimize button. 
    HTNOWHERE   On the screen background or on a dividing line between windows. 
    HTREDUCE   In a Minimize button. 
    HTRIGHT   In the right border of the window. 
    HTSIZE   In a size box (same as HTGROWBOX). 
    HTSYSMENU   In a Control menu or in a Close button in a child window. 
    HTTOP   In the upper horizontal border of the window. 
    HTTOPLEFT   In the upper-left corner of the window border. 
    HTTOPRIGHT   In the upper-right corner of the window border. 
    HTTRANSPARENT   In a window currently covered by another window. 
    HTVSCROLL   In the vertical scroll bar. 
    HTZOOM   In a Maximize button. 
      

  6.   

    Procedure TFommain.wmnchitTest(Var M: TWMNCHitTest);
    Begin
      If M.Result = htclient Then
      Begin
        M.Result := HTCAPTION;
      End;
      Inherited;
    End;inherited意思是继承原有的消息处理函数.
    你把inherited放到判断后面.开始判断的时候没有得到htClient消息.