answersLogoWhite

0

Start by creating a non-empty WIN32 application.

In your main source, include the standard I/O library:

#include

In the global variables section of your main source, add the following class declaration and object:

struct point

{

int x;

int y;

point():x(0),y(0){}

TCHAR* get() const

{

static TCHAR str[MAX_LOADSTRING];

_stprintf_s(str, MAX_LOADSTRING, "Mouse: %i,%i", x, y);

return(str);

}

};

point mouse_coordinate;

In your WndProc callback function, add the following message handler:

case WM_MOUSEMOVE:

mouse_coordinate.x=LOWORD(lParam);

mouse_coordinate.y=HIWORD(lParam);

RECT r;

GetClientRect(hWnd,&r);

InvalidateRect(hWnd,&r,TRUE);

break;

Finally, modify the WM_PAINT message handler as follows:

case WM_PAINT:

hdc = BeginPaint(hWnd, &ps);

// TODO: Add any drawing code here...

TextOut(hdc, 0, 0, mouse_coordinate.get(), _tcsnlen(mouse_coordinate.get(),MAX_LOADSTRING));

EndPaint(hWnd, &ps);

break;

Now run the application. The mouse coordinates will be printed at the top left of the client area.

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Write a program in c plus plus to implement macro processor?

Don't write, it is already written, google for 'cpp'.


What is stream operator in c plus plus?

There are two stream operators: << (insert or put) and >> (extract or get). Output streams implement the insertion operator, input streams implement the extraction operator and input/output streams implement both operators.


How do you implement insertion into AVL tree in C plus plus?

See related links for an example.


How to restart c plus plus program?

Exit the program and relaunch it.


Can you program games with c plus plus?

Yes, you can program games with C++.


Is there an answer book for the A plus program?

The A Plus Program is an initiative, not a test. So no, there is no answer book.


where can I find a plus size Minnie Mouse costume?

Halloween Express has a cute adult Minnie Mouse costume in plus sizes. http://www.halloweenexpress.com/minnie-mouse-costume-p-20949.html Ebay.com also has a pretty nice plus size collection.


What is the x-coordinate of the vertexy equals x2 - 8 plus 16?

4


What is the x coordinate of the vertex parabola defined by the following function 3x plus x plus 7x plus 4?

The given equation is not that of a parabola.


What is the coordinate pair to y equals 2x plus 5?

There are infinitely many coordinate pairs - the coordinates of each point on the infinite line defined by the equation.


If a cat is chasing a mouse the mouse will usually respond by running away and hiding What kind of stimulus is this?

external for A~plus


Why does sometimes when you run a program it will execute the previous program instead the current open program in C plus plus?

Because you aren't careful enough.