[英]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 can overwrite OnSetCursor to get a dynamic mouse cursor.您可以覆盖 OnSetCursor 以获得动态鼠标 cursor。 I just found a German tutorial.
我刚刚找到了一个德语教程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.