【问题标题】:Get Position from WM_LBUTTONDOWN SendMessage从 WM_LBUTTONDOWN SendMessage 获取位置
【发布时间】:2011-10-13 13:33:42
【问题描述】:

当 WM_LBUTTONDOWN 在 vb.net 中发送时,我想从参数中获取 x、y 位置。

我得到了这个来制作参数,但是我如何从中获得位置。

IntPtr lParam = (IntPtr)((y << 16) | x);

我的功能:

Protected Overrides Sub WndProc(ByRef m As Message)
  Select Case m.Msg
    Case WM_LBUTTONDOWN

      'Get the X, Y from m.lparam

    Case Else
      MyBase.WndProc(m)
  End Select
End Sub

更新:我刚试过,效果很好。

Dim pos As New System.Drawing.Point(CInt(m.LParam))

【问题讨论】:

  • 非常好的 .net 人员为Point 提供了有用的 Int32 构造函数。您应该将其写成答案,而不是编辑问题。

标签: vb.net sendmessage wndproc


【解决方案1】:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    If m.Msg = &H201 Then
        Dim pos As New Point(m.LParam.ToInt32())
        '--- etc...
    End If
    MyBase.WndProc(m)
End Sub

【讨论】:

  • 所以你也可以做VB!现在只卖870。 +1
【解决方案2】:

我刚试过,效果很好。

Dim pos As New System.Drawing.Point(CInt(m.LParam))

【讨论】:

    【解决方案3】:

    当收到 WM_LBUTTONDOWN 消息时,xpos = LOWORD(lParam) 和 yPos = HIWORD(lParam)。

    http://www.daniweb.com/software-development/vbnet/code/341269

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-17
      • 2012-05-27
      • 2019-02-19
      相关资源
      最近更新 更多