C++/c++

Advertisement


Question
i am a student knowing about c++ . i have learned functions ,arrays ,structures,classes,basic programming and some what of files and graphics.
can you tell me about how to use mouse pointer in c++ programming, using a simple programming ?
can you explain about the functions used also ?






THANKS!


Answer
Hello gureinder, thank you for the question.

For mouse movement, I am afraid I only know Windows OS specific calls. The functions SetMousePos() and GetMousePos() will get and set the position of the mouse, and ShowCursor(bool) will toggle its visibility. The get and set methods take a POINT structure. Here is an example:

POINT pnt;
pnt.x = 100;
pnt.y = 100;
SetMousePos(&pnt);

POINT newPnt;
GetMousePos(&newPnt);
std::cout << "The new mouse point is: " << newPnt.x << " " << newPnt.y << '\n';

This is how you use those functions.

If you need any further explantion, please do not hesistate to ask.

I hope this information was helpful.

- Eddie  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.