Strange PostMessage Problem
-
Hi, I'm having a strange problem trying to postmessage out of VB.NET. I have PostMessage defined as
Public Declare Function PostMessage \_ Lib "user32" \_ Alias "PostMessageA" \_ (ByVal hwnd As IntPtr, \_ ByVal wMsg As Long, \_ ByVal wParam As Long, \_ ByVal lParam As Long) As Long
The wMsg is arriving perfectly at hwnd, but wParam is always 0 and even stranger is lParam is always equal to the value that should be in wParam :confused: :confused: The wParam is defined as a long and has the value 10 when posting, lParam is defiend as Long and has the value Me.Handle.ToInt64() When the message arrives, though wParam = 0 and lParam = 10 Any ideas? This is driving me mad! Many thanks in advance Mark
-
Hi, I'm having a strange problem trying to postmessage out of VB.NET. I have PostMessage defined as
Public Declare Function PostMessage \_ Lib "user32" \_ Alias "PostMessageA" \_ (ByVal hwnd As IntPtr, \_ ByVal wMsg As Long, \_ ByVal wParam As Long, \_ ByVal lParam As Long) As Long
The wMsg is arriving perfectly at hwnd, but wParam is always 0 and even stranger is lParam is always equal to the value that should be in wParam :confused: :confused: The wParam is defined as a long and has the value 10 when posting, lParam is defiend as Long and has the value Me.Handle.ToInt64() When the message arrives, though wParam = 0 and lParam = 10 Any ideas? This is driving me mad! Many thanks in advance Mark
In VB6,
Long
was a 32-bit integer. In VB.NET,Long
is a 64-bit integer, andInteger
is the 32-bit integer. Unless you're working on a 64-bit version of Windows, you need to use 32-bit integers:Public Declare Function PostMessage _
Lib "user32" _
Alias "PostMessageA" _
(ByVal hwnd As IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer