Solved

Placing the x-coordinate of the cursor in a variable

Posted on 2004-08-11
3
137 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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