How do I display dynamic text at the mouse cursor via C++/MFC in a Win32 application

StackOverflow https://stackoverflow.com/questions/63429

  •  09-06-2019
  •  | 
  •  

Question

I would like to be able to display some dynamic text at the mouse cursor location in a win32 app, for instance to give an X,Y coordinate that would move with the cursor as though attached. I can do this during a mousemove event using a TextOut() call for the window at the mouse coordinates and invalidate a rectange around a stored last cursor position to clear up the previous output. However this can suffer from flickering and cause problems with other things being drawn in a window such as tracker boxes. Is there a better way to do this, perhaps using the existing cursor drawing/invalidating mechanism ?

Was it helpful?

Solution

You may want to consider a small transparent window that you move to follow the mouse. In particular, since Windows 2000, Layered windows seem to be the weapon of choice (confession: no personal experience there).

OTHER TIPS

You can do this via ToolTips - check out CToolTipCtrl.

If you want flicker free tracking ToolTips then you will need to derive your own classes from CToolTipCtrl that use the trackActivate messages.

You can overwrite OnSetCursor to get a dynamic mouse cursor. I just found a German tutorial.

German tutorial

English translated tutorial

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top