我试过移动窗体能做到效果,但移动标题栏就不行。。请帮帮忙,十万火急

解决方案 »

  1.   

    根据主窗体的位置,让子窗体自己判断移动
    MoveWindow(...,true);
    你看看是不是这个函数,我还是没有理解你的意思
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }
        procedure WMWindowPosChanged(var Msg: TWMWindowPosChanged);message WM_WINDOWPOSCHANGED;  public
        { Public declarations }
      end;var
      Form1: TForm1;const  uFlag = SWP_NOACTIVATE or SWP_NOZORDER or SWP_NOMOVE or SWP_NOSIZE;implementationuses Unit2;{$R *.dfm}{ TForm1 }procedure TForm1.WMWindowPosChanged(var Msg: TWMWindowPosChanged);
    var
      Rect: TRect;
       X, Y, Cx, Cy: Integer;
       uFlag2: UINT;
    begin
      inherited;
      if Form2 <> nil then   //如果子窗体存在
      begin
        GetWindowRect(Form2.Handle, Rect);    //获得子窗体的位置
        with Msg do
        begin
          X := WindowPos^.x + WindowPos^.cx;    //新X坐标
          Y := WindowPos^.y;                   //新Y坐标
          Cx := WindowPos^.cx;                 //新宽度
          Cy := WindowPos^.cy;                //新高度
        end;
        uFlag2 := uFlag;                //移动必要时
        if (Rect.Top <> Y) or (Rect.Left <> X) then
          uFlag2 := uFlag2 and (not SWP_NOMOVE);
        if (Rect.Bottom - Rect.Top <> Cy) or    //尺寸变更必要时
           (Rect.Right - Rect.Left <> Cx) then
          uFlag2 := uFlag2 and (not SWP_NOSIZE);
        if uFlag <> uFlag2 then                 //都必要时
          SetWindowPos(Form2.Handle, 0, X, Y, Cx, Cy, uFlag2);
        end;
    end;
    end.