0

刚开始使用 GUI Windows 编程。我在 Visual Studio C++ Wondows Forms 中工作。

我已经想出了如何获取鼠标坐标并将它们转储到双点坐标变量中,但是当我尝试访问 X 和 Y 值来操作它们时,我得到了......

error C2248: 'System::Drawing::Point::x' : cannot access private member declared in class 'System::Drawing::Point'

Point 变量称为 firstPoint,我正在尝试使用 firstPoint.X 和 firstPoint.Y 访问这些值。我想这不是正确的方法。

如何将值转换为 int 以便我可以弄乱它?Convert::ToInt32(firstPoint.x) 是引发错误的原因。

谷歌搜索不断向我发送指针主题而不是点坐标主题。

根据要求的附加代码:

private:
    /// <summary>
    /// Required designer variable.
    unsigned char ucRed, ucGrn, ucBlu;
    bool drawing;
    Point firstPoint, finalPoint;
    //int iShape, iX1,iY1,iX2,iY2;

private: System::Void panel1_Paint_1(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
     {
        Graphics^ g = e->Graphics;

 //create an ellipse with
 //  Black color
 //  start position = firstPoint mouse coordinate
 //  width = difference between firstPoint and finalPoint, height = difference between firstPoint and finalPoint


        g->DrawEllipse(Pens::Black,firstPoint.x,firstPoint.Y,(finalPoint.X-firstPoint.X),(finalPoint.Y-firstPoint.Y));
4

1 回答 1

0

使用带有大写字母的公共属性 X 和 Y(注意:区分大小写),x 和 y 是结构的私有成员变量。

http://msdn.microsoft.com/en-us/library/system.drawing.point.aspx

转换::ToInt32(firstPoint.X)

于 2012-10-22T08:22:26.603 回答