简体   繁体   English

如何在 Win32 应用程序中通过 C++/MFC 在鼠标 cursor 上显示动态文本

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

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.我希望能够在 win32 应用程序中的鼠标 cursor 位置显示一些动态文本,例如给出一个 X,Y 坐标,该坐标将随着 cursor 移动,就像附加的一样。 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. 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.然而,这可能会受到闪烁的影响,并导致在 window 中绘制的其他事物(例如跟踪器框)出现问题。 Is there a better way to do this, perhaps using the existing cursor drawing/invalidating mechanism?有没有更好的方法来做到这一点,也许使用现有的 cursor 绘图/无效机制?

You can do this via ToolTips - check out CToolTipCtrl .您可以通过 ToolTips 执行此操作 - 查看CToolTipCtrl

If you want flicker free tracking ToolTips then you will need to derive your own classes from CToolTipCtrl that use the trackActivate messages.如果您想要无闪烁跟踪工具提示,那么您需要从使用trackActivate消息的 CToolTipCtrl 派生您自己的类。

You may want to consider a small transparent window that you move to follow the mouse.您可能需要考虑一个小的透明 window,您可以移动它以跟随鼠标。 In particular, since Windows 2000, Layered windows seem to be the weapon of choice (confession: no personal experience there).特别是,自从 Windows 2000 以来, 分层windows 似乎是首选武器(坦白:没有个人经验)。

You can overwrite OnSetCursor to get a dynamic mouse cursor.您可以覆盖 OnSetCursor 以获得动态鼠标 cursor。 I just found a German tutorial.我刚刚找到了一个德语教程。

German tutorial 德语教程

English translated tutorial 英文翻译教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Win32控制台中隐藏鼠标光标? - How do I hide the mouse cursor in a Win32 console? 我如何决定对新的 C++ 项目使用 ATL、MFC、Win32 还是 CLR? - How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project? C ++,MFC,选项卡式文档界面应用程序,Win32 - C++, MFC, tabbed document interface application, Win32 如何在Visual C ++ 2008中将MFC应用程序项目添加到Win32应用程序项目 - How to add MFC application project to Win32 application project in Visual C++ 2008 如何在C ++ Win32应用程序中使用非托管DLL? - How do I use unmanaged DLL in C++ win32 application? MFC:在Win32文本区域(MFC应用程序)中执行过程时,异步(同时)显示过程的输出 - MFC: Display output of a process asynchronously(concurrently) while process is in execution in a win32 text area (mfc application) 双缓冲时如何掩盖旧文本? -Win32 C ++ - How do I cover up old text when double buffering? - Win32 C++ 如何从MFC应用程序调用函数的Win32 API版本? - How do I call the Win32 API version of a function from an MFC application? 如何从另一个C ++ win32控制台应用程序调用C ++ Win32 DLL - How Can I call a C++ Win32 DLL from another C++ win32 Console Application c ++ win32更改应用程序显示名称 - c++ win32 changing the application display name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM