请问如何使一个窗口按住标题栏后不可拖动?

解决方案 »

  1.   

    procedure WMNCHitTest(var Msg:TWMNCHitTest);message WM_NCHITTEST;procedure TForm1{或你定义的Form名}.WMNCHitTest(var Msg:TWMNCHitTest);
    begin
    DefaultHandler(Msg);
    if Msg.Result =HTCAPTION  then
    Msg.Result:= HTCLIENT;
    end;
      

  2.   

    用一下SDK的函数SetWindowPos把窗口设置为不能移动的
    BOOL SetWindowPos(
      HWND hWnd,             // handle to window
      HWND hWndInsertAfter,  // placement-order handle
      int X,                 // horizontal position
      int Y,                 // vertical position
      int cx,                // width
      int cy,                // height
      UINT uFlags            // window-positioning options
    );
    uFlags 这个参数为 SWP_NOMOVE