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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Heitmuller.

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

    private const int RF_TESTMESSAGE = 0xA123;

    [DllImport("user 32.dll", CharSet=CharSet .Auto, SetLastError=tr ue)]
    public static extern int SendMessage(Int Ptr hwnd,
    [MarshalAs(Unman agedType.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

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

    On Mar 9, 3:50 pm, "John Heitmuller." <john.heitmul.. .@jrfcorp.net>
    wrote:
    private const int RF_TESTMESSAGE = 0xA123;
    >
    [DllImport("user 32.dll", CharSet=CharSet .Auto, SetLastError=tr ue)]
    public static extern int SendMessage(Int Ptr hwnd,
    [MarshalAs(Unman agedType.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
    Try this (untested):

    Private Const RF_TESTMESSAGE As Integer = 41251

    <DllImport("use r32.dll", CharSet := CharSet.Auto, SetLastError :=
    True)_
    Public Shared Function SendMessage(ByV al hwnd As IntPtr,
    <MarshalAs(Unma nagedType.U4)_
    ByVal Msg As Integer, ByVal wParam As UInteger, ByVal lParam As ULong)
    As Integer
    End Function

    Comment

    • Herfried K. Wagner [MVP]

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

      "John Heitmuller." <john.heitmulle r@jrfcorp.netsc hrieb:
      private const int RF_TESTMESSAGE = 0xA123;
      >
      [DllImport("user 32.dll", CharSet=CharSet .Auto, SetLastError=tr ue)]
      public static extern int SendMessage(Int Ptr hwnd,
      [MarshalAs(Unman agedType.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.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • =?Utf-8?B?RGF2aWQgQW50b24=?=

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

        (Instant VB)
        Private Const RF_TESTMESSAGE As Integer = &HA123

        <DllImport("use r32.dll", CharSet:=CharSe t.Auto, SetLastError:=T rue)_
        Public Shared Function SendMessage(ByV al hwnd As IntPtr,
        <MarshalAs(Unma nagedType.U4)By Val Msg As Integer, ByVal wParam As UInteger,
        ByVal lParam As ULong) As Integer
        End Function
        --
        Source code converters: Convert between C#, C++, Java, VB, and Python with the most accurate and reliable source code converters

        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


        "John Heitmuller." wrote:
        private const int RF_TESTMESSAGE = 0xA123;
        >
        [DllImport("user 32.dll", CharSet=CharSet .Auto, SetLastError=tr ue)]
        public static extern int SendMessage(Int Ptr hwnd,
        [MarshalAs(Unman agedType.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
        >

        Comment

        • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

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



          "John Heitmuller." wrote:
          private const int RF_TESTMESSAGE = 0xA123;
          >
          [DllImport("user 32.dll", CharSet=CharSet .Auto, SetLastError=tr ue)]
          public static extern int SendMessage(Int Ptr hwnd,
          [MarshalAs(Unman agedType.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
          >
          http://www.pinvoke.net/ lists the following definition for SendMessage in
          VB.net:

          <DllImport("use r32.dll", SetLastError:=T rue, CharSet:=CharSe t.Auto)_
          Function SendMessage( _
          ByVal hWnd As HandleRef, _
          ByVal Msg As UInteger, _
          ByVal wParam As IntPtr, _
          ByVal lParam As IntPtr) As IntPtr
          End Function

          Comment

          • John Heitmuller.

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

            Thanks to everybody. With your help I got it working.

            Comment

            Working...