How to show a number that is updated consistantly?

Hello,
im using c++ and winapi and i can't figure out how to show a consistantly updated number in a dialog-based application.

Think im trying to retrieve the cursor position while moving it, and want to show its X and Y coordinate in two respective little boxes.
I started looking at CreateWindowEx() but found nothing of help.
Also googled pretty much but nothing still. And this is weird because i thought it should be a popular subject. But maybe i googled wrong..
I think there's SendMessage() or PostMessage() involved but i wouldn't know how to move on, nor if it's the preferable way to do it.

Anyone please?
Any help is much appreciated, thanks.
Ps: Im going to post this in "Beginners" section too.
1
2
#include <string>
#include <sstream> 

Then, inside your window procedure...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//...
    switch (message)                  
    {
        case WM_MOUSEMOVE:
        {
            HDC hdc = GetDC(hwnd);

            static POINTS point;
            point=MAKEPOINTS(lParam);

            std::stringstream buffer;
            buffer << point.x << ' ';
            buffer << point.y;

            std::string str_xy=buffer.str();
            static std::string str_empty="__________";

            TextOut(hdc,50,50,str_empty.c_str(),str_empty.size());
            TextOut(hdc,50,50,str_xy.c_str(),str_xy.size());

            ReleaseDC(hwnd,hdc);
        }

        break;
//... 
Last edited on
Look into the WM_MOUSEMOVE Message.

EDIT: m4ster r0shi beat me to it....
Last edited on
:P :D
Thanks :)
Marking topic as solved.
Last edited on
Topic archived. No new replies allowed.