private const int RF_TESTMESSAGE = 0xA123;
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int SendMessage(IntPtr hwnd,
[MarshalAs(UnmanagedType.U4)] int Msg, uint wParam, ulong lParam);
I'm trying to send a Windows message from a VB.NET 2005 app. I found
this example in C# that works fine, but I cannot figure out the VB
sysntax.
Thanks,
John
kimiraikkonen - 09 Mar 2008 15:01 GMT
On Mar 9, 3:50 pm, "John Heitmuller." <john.heitmul...@jrfcorp.net>
wrote:
> private const int RF_TESTMESSAGE = 0xA123;
>
[quoted text clipped - 8 lines]
> Thanks,
> John
Try this (untested):
Private Const RF_TESTMESSAGE As Integer = 41251
<DllImport("user32.dll", CharSet := CharSet.Auto, SetLastError :=
True)> _
Public Shared Function SendMessage(ByVal hwnd As IntPtr,
<MarshalAs(UnmanagedType.U4)> _
ByVal Msg As Integer, ByVal wParam As UInteger, ByVal lParam As ULong)
As Integer
End Function
Herfried K. Wagner [MVP] - 09 Mar 2008 15:32 GMT
"John Heitmuller." <john.heitmuller@jrfcorp.net> schrieb:
> private const int RF_TESTMESSAGE = 0xA123;
>
> [DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
> public static extern int SendMessage(IntPtr hwnd,
> [MarshalAs(UnmanagedType.U4)] int Msg, uint wParam, ulong lParam);
Are you sure the parameter types for the 'wParam' and 'lParam' parameters
are correct? Note that they are 'IntPtr's, which means that they are 32-bit
types on 32-bit Windows versions and 64-bit types on 64-bit versions.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
David Anton - 09 Mar 2008 17:06 GMT
(Instant VB)
Private Const RF_TESTMESSAGE As Integer = &HA123
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function SendMessage(ByVal hwnd As IntPtr,
<MarshalAs(UnmanagedType.U4)> ByVal Msg As Integer, ByVal wParam As UInteger,
ByVal lParam As ULong) As Integer
End Function

Signature
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
Java to C#
Java to VB
Instant C#: convert VB to C#
Instant VB: convert C# to VB
Instant C++: VB, C#, or Java to C++/CLI
> private const int RF_TESTMESSAGE = 0xA123;
>
[quoted text clipped - 8 lines]
> Thanks,
> John
Family Tree Mike - 09 Mar 2008 17:22 GMT
> private const int RF_TESTMESSAGE = 0xA123;
>
[quoted text clipped - 8 lines]
> Thanks,
> John
http://www.pinvoke.net/ lists the following definition for SendMessage in
VB.net:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Function SendMessage( _
ByVal hWnd As HandleRef, _
ByVal Msg As UInteger, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As IntPtr
End Function
John Heitmuller. - 09 Mar 2008 23:00 GMT
Thanks to everybody. With your help I got it working.