Imports System.Runtime.InteropServices Imports System.Text Public Class Native Public Delegate Function CallbackHandler(handle As IntPtr, parameter As Integer) As Boolean Public Shared Function ExcludeClipRect(hdc As IntPtr, nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer) As Integer End Function #Region "Constants" Friend Const EM_SETCUEBANNER As Integer = &H1501 Friend Const CB_SETCUEBANNER As Integer = &H1703 #End Region #Region "Function" #Region "user32.dll" Shared Function SetWindowPos(hWnd As IntPtr, hWndInsertAfter As IntPtr, X As Integer, Y As Integer, cx As Integer, cy As Integer, uFlags As UInteger) As Boolean End Function Shared Function GetWindowLong(hWnd As IntPtr, nIndex As Integer) As Integer End Function Shared Function RegisterWindowMessage(id As String) As Integer End Function Shared Function RegisterHotKey(hWnd As IntPtr, id As Integer, fsModifiers As Integer, vk As Integer) As Boolean End Function Shared Function MapVirtualKey(wCode As Integer, wMapType As Integer) As Integer End Function Shared Function UnregisterHotKey(hWnd As IntPtr, id As Integer) As Boolean End Function Shared Function GetForegroundWindow() As IntPtr End Function Shared Function GetWindowThreadProcessId(hwnd As IntPtr, ByRef lpdwProcessId As Integer) As Integer End Function Shared Function SetForegroundWindow(handle As IntPtr) As Boolean End Function Shared Function GetWindowModuleFileName(hwnd As IntPtr, lpszFileName As StringBuilder, cchFileNameMax As UInteger) As UInteger End Function Shared Function SendMessage(handle As IntPtr, message As Int32, wParam As IntPtr, lParam As IntPtr) As IntPtr End Function Shared Function SendMessage(hWnd As IntPtr, Msg As Int32, wParam As IntPtr, lParam As String) As IntPtr End Function Shared Function SendMessage(hWnd As IntPtr, Msg As Int32, wParam As Integer, lParam As Integer) As IntPtr End Function Shared Function SendMessage(hWnd As IntPtr, Msg As Int32, wParam As Integer, lParam As String) As IntPtr End Function Shared Function SendMessage(hWnd As IntPtr, Msg As Int32, ByRef wParam As IntPtr, lParam As StringBuilder) As IntPtr End Function Shared Function SendMessageTimeout(windowHandle As IntPtr, msg As Integer, wParam As IntPtr, lParam As IntPtr, flags As Integer, timeout As Integer, ByRef result As IntPtr) As IntPtr End Function Shared Function PostMessage(hwnd As IntPtr, wMsg As Integer, wParam As IntPtr, lParam As IntPtr) As IntPtr End Function Shared Sub ReleaseCapture() End Sub Public Shared Function GetWindowRect(hWnd As IntPtr, ByRef lpRect As RECT) As Boolean End Function Public Shared Function GetWindowDC(hWnd As IntPtr) As IntPtr End Function Public Shared Function ReleaseDC(hWnd As IntPtr, hDC As IntPtr) As Integer End Function #End Region #Region "kernel32.dll" Shared Function LoadLibrary(path As String) As IntPtr End Function Shared Function FreeLibrary(hModule As IntPtr) As Boolean End Function Shared Function FormatMessage(dwFlags As Integer, lpSource As IntPtr, dwMessageId As Integer, dwLanguageId As Integer, ByRef lpBuffer As String, nSize As Integer, Arguments As IntPtr) As Integer End Function #End Region Shared Function SetWindowTheme(hWnd As IntPtr, pszSubAppName As String, pszSubIdList As String) As Integer End Function Shared Function AssocQueryString( flags As UInteger, str As UInteger, pszAssoc As String, pszExtra As String, pszOut As StringBuilder, ByRef pcchOut As UInteger) As UInteger End Function #End Region #Region "Structures" Public Structure RECT Public Left As Integer Public Top As Integer Public Right As Integer Public Bottom As Integer Sub New(r As Rectangle) Left = r.Left Top = r.Top Right = r.Right Bottom = r.Bottom End Sub Public Sub New(left As Integer, top As Integer, right As Integer, bottom As Integer) Me.Left = left Me.Top = top Me.Right = right Me.Bottom = bottom End Sub Function ToRectangle() As Rectangle Return Rectangle.FromLTRB(Left, Top, Right, Bottom) End Function End Structure Public Structure SHFILEINFO Public hIcon As IntPtr Public iIcon As Integer Public dwAttributes As Integer Public szDisplayName As String Public szTypeName As String End Structure Public Structure NMHDR Public hwndFrom As Integer Public idFrom As Integer Public code As Integer End Structure Public Structure NCCALCSIZE_PARAMS Public rgrc0, rgrc1, rgrc2 As RECT Public lppos As IntPtr End Structure #End Region End Class Public Class Taskbar Private Taskbar As ITaskbarList3 = DirectCast(New TaskBarCommunication(), ITaskbarList3) Property Handle As IntPtr Public Sub New(handle As IntPtr) Me.Handle = handle End Sub Private Interface ITaskbarList3 'ITaskbarList Sub HrInit() Sub AddTab(hwnd As IntPtr) Sub DeleteTab(hwnd As IntPtr) Sub ActivateTab(hwnd As IntPtr) Sub SetActiveAlt(hwnd As IntPtr) 'ITaskbarList2 Sub MarkFullscreenWindow(hwnd As IntPtr, fFullscreen As Boolean) 'ITaskbarList3 Sub SetProgressValue(hwnd As IntPtr, ullCompleted As UInt64, ullTotal As UInt64) Sub SetProgressState(hwnd As IntPtr, state As TaskbarStates) End Interface Private Class TaskBarCommunication End Class Public Sub SetState(taskbarState As TaskbarStates) Taskbar.SetProgressState(Handle, taskbarState) End Sub Public Sub SetValue(progressValue As Double, progressMax As Double) Taskbar.SetProgressValue(Handle, CULng(Math.Truncate(progressValue)), CULng(Math.Truncate(progressMax))) End Sub End Class Public Enum TaskbarStates NoProgress = 0 Indeterminate = &H1 Normal = &H2 [Error] = &H4 Paused = &H8 End Enum