Placing the x-coordinate of the cursor in a variable

To test whether I indeed have the value of the x-coordinate placed in the variable X upon clicking on the form I create a project with the following code in it:

private: System::Void Form1_MouseDown(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)                     
               points->Add( __box( Point( e->X, e->Y ) ) );
               MessageBox::Show( e->X.ToString(), e->Y.ToString());

with the following included in the IntializeComponent function:

this->MouseDown += new System::Windows::Forms::MouseEventHandler(this, Form1_MouseDown);

Above code works very well.

However, when placing the same code (except for the change of the name of the form) in my main project within the form (say, plotting.h) the same:

private: System::Void plotting_MouseDown(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)                     
            points->Add( __box( Point( e->X, e->Y ) ) );
                MessageBox::Show( e->X.ToString(), e->Y.ToString() );


this->MouseDown += new System::Windows::Forms::MouseEventHandler(this, plotting_MouseDown);

gives me the following errors:

plotting1.h(193): error C2065: 'points' : undeclared identifier
plotting1.h(193): error C2227: left of '->Add' must point to class/struct/union

Notice that upon compiling even the name of the form is changed from plotting.h to plotting1.h. What could be the reason for that?
Who is Participating?
NetminderConnect With a Mentor Commented:
User resolved; closed, 250 points refunded.

Site Admin
judicoAuthor Commented:
I just fixed it. I've forgotten to place 'using namespace <whatever>;' in plotting1.cpp. The rest of the code is

private: System::Void plotting1_MouseDown(System::Object *  sender, System::Windows::Forms::MouseEventArgs *  e)                     
               points->Add( __box( Point( e->X, e->Y ) ) );
             MessageBox::Show( e->X.ToString(), e->Y.ToString() );


this->MouseDown += new System::Windows::Forms::MouseEventHandler(this, plotting1_MouseDown);
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.