Results 1 to 6 of 6

Thread: Pointer to a structure?

  1. #1

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Pointer to a structure?

    I'm doing this:
    SendMessage(hWnd, LVM_GETITEM, Nothing, @), which @ should be a pointer to a structure called LVITEM, which I've made, but how do I make a pointer to a structure in Visual Basic .NET 2008??

    IE:
    Code:
    Dim liItem As New LVITEM()
    
    SendMessage(hWnd, LVM_GETITEM, Nothing, Pointer(liItem))
    How do I do this?

    Cheers
    Icyculyr

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Pointer to a structure?

    I'm sure there's a method in the InteropServices namespace that is called something like PtrToStructure that will do what you want. I used it the other day, I'll find out its exact name/location later if you havent already got it

    EDIT: actually having read your question again, I think your going about this the wrong way. You dont want to be going from a pointer to a structure, you want to be going from a structure to a pointer. I'll see if there's a method for that, I think there is..
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Pointer to a structure?

    Yeah, here it is:
    vb Code:
    1. System.Runtime.InteropServices.Marshal.StructureToPtr(STRUCTURE_HERE, POINTER_HERE, True)
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: Pointer to a structure?

    Thanks, does anyone know what the value for LVM_GETITEM and LVM_DELETEITEM??

    Cheers
    Icyculyr

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Pointer to a structure?

    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6

    Thread Starter
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: Pointer to a structure?

    Thanks, 2 things, How would I write out the LVITEM structure it's very complex (to me) to convert to VB.NET 08, I have tried, and I really doubt it would work... can anyone help with that?

    LVITEM (Mine)
    Code:
    #Region " [LVITEM] "
        Public Structure LVITEM
            Dim mask As UInteger
            Dim iItem As Integer
            Dim iSubItem As Integer
            Dim state As UInteger
            Dim stateMask As UInteger
            Dim pszText As String
            Dim cchTextMax As Integer
            Dim iImage As Integer
            Dim lParam As IntPtr
            Dim iIndent As Integer
            Dim iGroupId As Integer
            Dim cColumns As UInteger
            Dim puColumns As IntPtr
        End Structure
    #End Region
    Also, I did not see the value for LVM_GETITEM, I know how to use it, but when using the SendMessage API, what value would LVM_GETITEM have, would it be 1300? or 5610, I did not see any value on the MSDN page you gave me.

    Cheers
    Icyculyr

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width