Imports System.Runtime.InteropServices

Namespace Win32

    ''' <summary>
    ''' A callback to a Win32 window procedure (wndproc).
    ''' </summary>
    ''' <param name="hWnd">The handle to the window receiving a message.</param>
    ''' <param name="msg">The message.</param>
    ''' <param name="wParam">The message's parameters.</param>
    ''' <param name="lParam">The message's parameters.</param>
    ''' <returns>An integer specific to the given message (as described in MSDN).</returns>
    ''' <remarks></remarks>
    <CLSCompliant(False)> _
    Public Delegate Function WndProc(ByVal hWnd As IntPtr, ByVal msg As UInteger, ByVal wParam As UInteger, ByVal lParam As Integer) As Integer

    ''' <summary>
    ''' Provides a collection of native Win32 methods.
    ''' </summary>
    ''' <remarks></remarks>
    Public NotInheritable Class NativeMethods

        Public Const GWL_WNDPROC As Integer = -4

        Public Shared Function HIWORD(ByVal value As Integer) As Short
            Return CType(value >> 16, Short)
        End Function

        Public Shared Function LOWORD(ByVal value As Integer) As Short
            Return CType(value And UShort.MaxValue, Short)
        End Function

#Region "P/Invokes"

        <DllImport("Coredll.dll", EntryPoint:="CallWindowProc", SetLastError:=True)> _
        Friend Shared Function CallWindowProc(ByVal lPrevWndFunc As IntPtr, ByVal hWnd As IntPtr, ByVal msg As UInteger, ByVal wParam As UInteger, ByVal lParam As Integer) As Integer
        End Function

        <DllImport("Coredll.dll", EntryPoint:="DefWindowProc", SetLastError:=True)> _
        Friend Shared Function DefWindowProc(ByVal hWnd As IntPtr, ByVal msg As UInteger, ByVal wParam As UInteger, ByVal lParam As Integer) As Integer
        End Function

        <DllImport("Coredll.dll", EntryPoint:="DispatchMessage", SetLastError:=True)> _
        Friend Shared Function DispatchMessage(ByRef lpMsg As MSG) As Boolean
        End Function

        <DllImport("Coredll.dll", EntryPoint:="GetMessage", SetLastError:=True)> _
        Friend Shared Function GetMessage(ByRef lpMsg As MSG, ByVal hWnd As IntPtr, ByVal wMsgFilterMin As UInteger, ByVal wMsgFilterMax As UInteger) As Boolean
        End Function

        <DllImport("Coredll.dll", EntryPoint:="PeekMessage", SetLastError:=True)> _
        Friend Shared Function PeekMessage(ByRef lpMsg As MSG, ByVal hWnd As IntPtr, ByVal wMsgFilterMin As UInteger, ByVal wMsgFilterMax As UInteger, ByVal wRemoveMsg As UInteger) As Boolean
        End Function

        <DllImport("Coredll.dll", EntryPoint:="PostQuitMessage", SetLastError:=True)> _
        Friend Shared Sub PostQuitMessage(ByVal nExitCode As Integer)
        End Sub

        <DllImport("Coredll.dll", EntryPoint:="SetWindowLong", SetLastError:=True)> _
        Friend Shared Function SetWindowLong(ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal dwNewLong As IntPtr) As IntPtr
        End Function

        <DllImport("Coredll.dll", EntryPoint:="ShowWindow", SetLastError:=True)> _
        Friend Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As SW) As Boolean
        End Function

        <DllImport("Coredll.dll", EntryPoint:="TranslateMessage", SetLastError:=True)> _
        Friend Shared Function TranslateMessage(ByRef lpMsg As MSG) As Boolean
        End Function

#End Region

    End Class

End Namespace