我想获得相对于我的画布的鼠标位置。 我知道通常是这样完成的:Mouse.GetPosition(my_canvas); 我听说在透明画布上执行此操作时遇到问题。 我的画布不是透明的,但是看起来如下所示... 该编辑器是从画布派生的自定义控件。 我的画布位于屏幕的右下角。 现在, ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
我必须在执行DragDrop完整控件的过程中绘制一些东西。 我从控件复制屏幕并进行绘制。 该图像然后用作光标。
问题在于,在光标中生成的图像需要Hospot,它取决于鼠标的位置。 但是,如何在GiveFeedback事件中获得正确的位置? 在我使用Control.MousePosition的版本中,但是图片来回摆动。 这里是事件代码:
Private Sub Panel1_GiveFeedback(sender As Object, e As GiveFeedbackEventArgs) Handles Panel1.GiveFeedback
Dim Pan As Panel = sender
Dim pMouseScreen = Control.MousePosition, pMouseClient = Pan.PointToClient(pMouseScreen)
Dim RPanelClient = Pan.ClientRectangle, RPanelScreen = Pan.RectangleToScreen(RPanelClient)
Using BMP As New Bitmap(RPanelClient.Size.Width, RPanelClient.Size.Height)
Using Gr = System.Drawing.Graphics.FromImage(BMP)
Gr.CopyFromScreen(RPanelScreen.Location, Point.Empty, BMP.Size)
Gr.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
Using P As New Pen(Color.Black, 5)
Dim P1 = New Point(0, pMouseClient.Y), P2 = New Point(RPanelClient.Right - 1, pMouseClient.Y)
Gr.DrawLine(P, P1, P2)
End Using
Dim Cur = Cursors.Default '
Dim Rcursor = New Rectangle(pMouseClient, Cur.Size)
Cur.Draw(Gr, Rcursor)
End Using
e.UseDefaultCursors = False
Cursor.Current = CreateCursorFromBMP(BMP, pMouseClient)
End Using
结束子
怎么做对?
托尔斯滕的许多感谢和问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.