To rh:
我知道你说的方法的原理,而且也部分试验过.
请给出你的截获窗体移动消息及自画本身的代码,好吗?
我想你的这种方法也许可行,但是可能会有闪烁.

解决方案 »

  1.   

    实现在移动窗口时,显示的是窗口而非虚框 
        在Windows系统中,需要在移动窗口时显示窗口和虚框,可以调用Windows API函数实现: 
        SystemParametersInfo(SPI_GETDRAGFULLWINDOWS,TRUE,NULL,0);  
      

  2.   

    procedure TForm1.wmmove(var msg: tmessage);message wm_moving
    var
      p:^trect;
    begin
      p:=pointer(msg.lParam);
      left:=p^.Left;
      top:=p^.Top;
      msg.Result:=integer(true);
      msg.Result:=1;
      SetWindowPos(handle,HWND_TOP ,p^.Left,p^.Top,p^.Right-p^.Left,p^.Bottom-p^.Top,SWP_SHOWWINDOW );
      inherited;
    end;
      

  3.   

    不过我测试了一下,闪烁比较厉害,比Winamp还闪烁一些,可能应该还要优化一下。
      

  4.   

    呵呵,我直接repaint算了咯~~省得代码难得敲
      

  5.   

    呵呵,是不是被打击,不好意思!!repaint不行!Kingron(WinAPI)的方法也不行!总之都达不到预期的效果!!不过小弟已经找到一个控件可以实现,可以研究一下它的代码!!
      

  6.   

    贴出来看看先?!
    xixi~~repaint当然不可以了,慢得很:)
      

  7.   

    在窗体中放一个ApplicationEvents控件,在它的OnMessage事件中//pt,IsDown为全局变量procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    var
      P: TPoint;
      R: TRect;
    begin
      if (msg.message = WM_NCMOUSEMOVE) or (msg.message = WM_MOUSEMOVE) then
      begin
        if IsDown then
        begin
          GetCursorPos(p);
          SetBounds(p.x - pt.x, p.y - pt.y, Width, Height);
          GetWindowRect(Handle, r);
          ClipCursor(@r);
        end;
      end else if (msg.message = WM_NCLBUTTONDOWN) then
      begin
        if msg.wParam = HTCAPTION then
        begin
          IsDown := True;
          GetCursorPos(pt);
          pt.x := pt.x - Left;
          pt.y := pt.y - Top;
          Handled := True;
          GetWindowRect(Handle, r);
          ClipCursor(@r);
        end;
      end else if (msg.message = WM_NCLBUTTONUP) or (msg.message = WM_LBUTTONUP) then
      begin
        IsDown := False;
        ClipCursor(nil);
      end;
    end;以上方法可以实现,但是不够完美,可供参考!