问题描述
我想通过调用ToolTip.Show(字符串,IWin32Window,点)显示工具提示的,但我想做到像什么Windows资源管理器 - 显示在光标的左下角的提示。
I'm trying to display the tooltip by calling "ToolTip.Show(String, IWin32Window, Point)", but I wanted to do it like what Windows explorer does - displays the tooltip at the lower left corner of the cursor.
我可以通过MousePosition获得鼠标的位置,但我怎么能得到它的左下角位置?
I could get the mouse position by "MousePosition", but how could I get its lower left corner position?
谢谢,
推荐答案
如果没有人想出了一个更好的答案,你可以试试这个:
If nobody comes up with a better answer you can try this:
toolTip1.Show("Am I where you want me to be?", this, this.PointToClient(MousePosition).X,
this.PointToClient(MousePosition).Y + Cursor.Size.Height * 2);
通过与X / Y参数打调整文字的定位。它的工作原理我的机器上,但我不知道它会怎样看在不同的设置
Adjust the text positioning by playing with the x/y parameters. It works on my machine but I'm not sure how it would look under different settings.
工具提示乐趣。提示:把你的窗体的MouseMove事件此行
ToolTip fun tip: put this line in your Form's MouseMove event.
这篇关于获取当前光标左下方位置,使工具提示可以正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!