0

I'm trying move my form with using left mouse button. I have this:

if(e->Button == Windows::Forms::MouseButtons::Left)
{
    Point^ mousePos = gcnew Point();
    mousePos = Control::MousePosition;
        mousePos->Offset(mouse_offset->X,mouse_offset->Y);
    Location = mousePos;
}

Code seems ok, but Visual returning error:

error C2664: 'void System::Windows::Forms::Control::Location::set(System::Drawing::Point)' : cannot convert parameter 1 from 'System::Drawing::Point ^' to 'System::Drawing::Point'

I don't understand - I created variable mousePos as a Point^. Do you have any idea what's wrong?

4

2 回答 2

1

Point 是一个值类(尽管不是不可变的)。为什么要在(托管)堆上分配一个?我在这个函数中没有看到任何证明这样做的理由。

于 2013-05-30T12:44:33.327 回答
1

问题是该方法需要一个Point,而您正在向它传递一个Point ^(托管指针Point- weeee,这里的“点”太多......)。

于 2013-05-30T12:29:07.690 回答