怎么实现拖动form上的一个image时,让form跟着移动.

解决方案 »

  1.   

    你可以欺骗Windows,让它认为你拖的是Caption.
      

  2.   

    你将form的image的移动的事件响应给form
    我瞎说的
    不知道行不行。
      

  3.   

    全局变量
    PrePoint: TPoint;
    Down: Boolean;procedure TForm1.Image1MouseDown(Button: TMouseButton; Shift: TShiftState; X,
      Y: Integer);
    begin
        if (Button = MBLeft) then
        begin
            Down := true;
            Screen.Cursor := crSizeAll;
            GetCursorPos(PrePoint);
        end;
    end;procedure TForm1.Image1MouseMove(Shift: TShiftState; X, Y: Integer);
    Var
        NowPoint: TPoint;
    begin
        if Down then
        begin
            GetCursorPos(NowPoint);
            Self.Parent.Left := Self.Parent.Left + NowPoint.X - PrePoint.X;
            Self.Parent.Top := Self.Parent.Top + NowPoint.Y - PrePoint.Y;
            PrePoint := NowPoint;
        end;
    end;procedure TForm1.Image1MouseUp(Button: TMouseButton; Shift: TShiftState; X,
      Y: Integer);
    begin
        if (Button = MBLeft) and Down then
        begin
            Down := False;
            Screen.Cursor := crDefault;
        end;
    end;