繁体   English   中英

在GiveFeedback-Event中获取当前的鼠标位置

[英]Get Current Mouse-Position in GiveFeedback-Event

我必须在执行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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM