Solved

Placing the x-coordinate of the cursor in a variable

Posted on 2004-08-11
3
138 Views
Last Modified: 2010-05-18
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() );
                  }

and

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?
0
Comment
Question by:judico
3 Comments
 

Author Comment

by:judico
ID: 11778895
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() );
                  }

with

this->MouseDown += new System::Windows::Forms::MouseEventHandler(this, plotting1_MouseDown);
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 11859259
User resolved; closed, 250 points refunded.

Netminder
Site Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question