Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

What is the equivalent VB syntax for this c# code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Heitmuller. - 09 Mar 2008 14:50 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.