VB.NET; HDC difference since VB6?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SanderK
    New Member
    • Jan 2008
    • 1

    #1

    VB.NET; HDC difference since VB6?

    Hello,

    In VB6, I have a certain function that draws a 'tileset' to a picturebox. The function is from a self-written API in C++. This is how it is written in VB6;

    Code:
            Private Declare Function GFXdrawTileset Lib "actkrt3.dll" ( _
                                                ByVal file As String, _
                                                ByVal hdc As IntPtr, _
                                                ByVal startIdx As Integer, _
                                                ByVal pxWidth As Integer, _
                                                ByVal pxHeight As Integer, _
                                               ByVal isometric As Boolean) As Long
    The code works. Now I declared it like this in VB.NET;
    Code:
         <DllImport("C:\Program Files\Toolkit3\actkrt3.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
            Private Shared Function GFXdrawTileset( _
                                                ByVal file As String, _
                                                ByVal hdc As IntPtr, _
                                                ByVal startIdx As Integer, _
                                                ByVal pxWidth As Integer, _
                                                ByVal pxHeight As Integer, _
                <MarshalAs(UnmanagedType.Bool)> ByVal isometric As Boolean) As Integer
    
        End Function
    I'm 100% certain all parameters are correct; except for the hdc one. I simply tried "Picturebox.Han dle", and even "GetDC(Pictureb ox.Handle)" (declared GetDC from user32.dll), but it's not working.

    Does anyone know if there's a difference in VB.NET that I don't know about which can cause this?

    Thanks.
  • leoiser
    New Member
    • Jul 2007
    • 41

    #2
    just put Handle instead of Picturebox.Hand le , hope it will work ...


    Originally posted by SanderK
    Hello,

    In VB6, I have a certain function that draws a 'tileset' to a picturebox. The function is from a self-written API in C++. This is how it is written in VB6;

    Code:
            Private Declare Function GFXdrawTileset Lib "actkrt3.dll" ( _
                                                ByVal file As String, _
                                                ByVal hdc As IntPtr, _
                                                ByVal startIdx As Integer, _
                                                ByVal pxWidth As Integer, _
                                                ByVal pxHeight As Integer, _
                                               ByVal isometric As Boolean) As Long
    The code works. Now I declared it like this in VB.NET;
    Code:
         <DllImport("C:\Program Files\Toolkit3\actkrt3.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
            Private Shared Function GFXdrawTileset( _
                                                ByVal file As String, _
                                                ByVal hdc As IntPtr, _
                                                ByVal startIdx As Integer, _
                                                ByVal pxWidth As Integer, _
                                                ByVal pxHeight As Integer, _
                <MarshalAs(UnmanagedType.Bool)> ByVal isometric As Boolean) As Integer
    
        End Function
    I'm 100% certain all parameters are correct; except for the hdc one. I simply tried "Picturebox.Han dle", and even "GetDC(Pictureb ox.Handle)" (declared GetDC from user32.dll), but it's not working.

    Does anyone know if there's a difference in VB.NET that I don't know about which can cause this?

    Thanks.

    Comment

    Working...