#Include <WinAPIEx.au3>
#Include <WindowsConstants.au3>
Global Const $IDC_ARROW = 32512
Global Const $tagWNDCLASSEX = 'uint Size;uint Style;ptr hWndProc;int ClsExtra;int WndExtra;ptr hInstance;ptr hIcon;ptr hCursor;ptr hBackground;ptr MenuName;ptr ClassName;ptr hIconSm'
Global Const $sClass = 'MyWindowClass'
Global Const $sName = 'MyProg'
$tWndClassEx = DllStructCreate($tagWNDCLASSEX)
$hWndProc = DllCallbackRegister('_MyWndProc', 'lresult', 'hwnd;uint;wparam;lparam')
$hInstance = _WinAPI_GetModuleHandle(0)
$hCursor = _WinAPI_LoadCursor(0, $IDC_ARROW)
$tIcon = DllStructCreate('ptr;ptr')
_WinAPI_ExtractIconEx('shell32.dll', 130, DllStructGetPtr($tIcon, 1), DllStructGetPtr($tIcon, 2), 1)
$hBrush = _WinAPI_CreateSolidBrush(_WinAPI_GetSysColor($COLOR_3DFACE))
$tClass = DllStructCreate('wchar[' & StringLen($sClass) + 1 & ']')
DllStructSetData($tClass, 1, $sClass)
DllStructSetData($tWndClassEx, 'Size', DllStructGetSize($tWndClassEx))
DllStructSetData($tWndClassEx, 'Style', 0)
DllStructSetData($tWndClassEx, 'hWndProc', DllCallbackGetPtr($hWndProc))
DllStructSetData($tWndClassEx, 'ClsExtra', 0)
DllStructSetData($tWndClassEx, 'WndExtra', 0)
DllStructSetData($tWndClassEx, 'hInstance', $hInstance)
DllStructSetData($tWndClassEx, 'hIcon', DllStructGetData($tIcon, 1))
DllStructSetData($tWndClassEx, 'hCursor', $hCursor)
DllStructSetData($tWndClassEx, 'hBackground', $hBrush)
DllStructSetData($tWndClassEx, 'MenuName', 0)
DllStructSetData($tWndClassEx, 'ClassName', DllStructGetPtr($tClass))
DllStructSetData($tWndClassEx, 'hIconSm', DllStructGetData($tIcon, 2))
DllCall('user32.dll', 'dword', 'RegisterClassExW', 'ptr', DllStructGetPtr($tWndClassEx))
$hWnd = DllCall('user32.dll', 'hwnd', 'CreateWindowExW', 'dword', 0, 'wstr', $sClass, 'str', $sName, 'dword', BitOR($WS_CAPTION, $WS_POPUPWINDOW, $WS_VISIBLE), 'int', 200, 'int', 200, 'int', 400, 'int', 400, 'hwnd', 0, 'hwnd', 0, 'hwnd', $hInstance, 'ptr', 0)
$hWnd = $hWnd[0]
$Exit = 0
While 1
Sleep(100)
If $Exit Then
ExitLoop
EndIf
WEnd
DllCall('user32.dll', 'dword', 'UnregisterClassW', 'wstr', $sClass, 'ptr', $hInstance)
DllCallbackFree($hWndProc)
_WinAPI_DestroyCursor($hCursor)
For $i = 1 To 2
_WinAPI_DestroyIcon(DllStructGetData($tIcon, $i))
Next
Func _MyWndProc($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_CLOSE
$Exit = 1
EndSwitch
Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>_MyWndProc