Hello, I've been searching the internet and i haven't been able to find anything on my problem.

Anyways, I'm trying to read cursor positioning on my screen, and send it to a variable. Just to make things easier, what would I type in the code region for a button;

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
{
    //this is where i need to put the code
}

P.S. If i need to include any headers, please tell me what they are!

Recommended Answers

All 4 Replies

"System::EventArgs^ e"

the var, e, is the event arguments.

int x = e.X;
int y = e.Y;

should get the x,y coordinates relative to the screen. No extra headers needed I believe...

Yes, But how about reading mouse input reletive to the window? Is there anything diferent there?

For relative to the screen, just subtract the form location from the mouse location:

(With VS2010)

int x = e->X - this->Location.X;
int y = e->Y - this->Location.Y;

That shouldn't be too hard! Thanks a lot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.