#Include "windows.bi" Const As String g_szClassName = "myWindowClass" Dim Shared As HMODULE hInstance Dim Shared As ZString Ptr lpCmdLine ' Step 4: the Window Procedure Function WndProc(hwnd As HWND, msg As ULong, wParam As WPARAM, lParam As LPARAM) As LRESULT Select Case msg Case WM_CLOSE DestroyWindow(hwnd) Case WM_DESTROY PostQuitMessage(0) Case Else Return DefWindowProc(hwnd, msg, wParam, lParam) End Select Return 0 End Function Function WinMain(hInstance As HINSTANCE, hPrevInstance As HINSTANCE, lpCmdLine As LPSTR, _ nCmdShow As Long) As Long Dim As WNDCLASSEX wc Dim As HWND hwnd Dim As MSG Msg 'Step 1: Registering the Window Class wc.cbSize = SizeOf(WNDCLASSEX) wc.style = 0 wc.lpfnWndProc = @WndProc wc.cbClsExtra = 0 wc.cbWndExtra = 0 wc.hInstance = hInstance wc.hIcon = LoadIcon(NULL, IDI_APPLICATION) wc.hCursor = LoadCursor(NULL, IDC_ARROW) wc.hbrBackground = Cast(HBRUSH, COLOR_WINDOW + 1) wc.lpszMenuName = NULL wc.lpszClassName = @g_szClassName wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION) If RegisterClassEx(@wc) = 0 Then MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION Or MB_OK) Return 0 EndIf ' Step 2: Creating the Window hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, _ g_szClassName, _ "The title of my window", _ WS_OVERLAPPEDWINDOW, _ CW_USEDEFAULT, CW_USEDEFAULT, 240, 120, _ NULL, NULL, hInstance, NULL) If hwnd = NULL Then MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION Or MB_OK) Return 0 EndIf ShowWindow(hwnd, nCmdShow) UpdateWindow(hwnd) ' Step 3: The Message Loop Do While GetMessage(@msg,NULL,0,0) TranslateMessage(@msg) DispatchMessage(@msg) Loop Return msg.wParam End Function ' Program start hInstance = GetModuleHandle(NULL) lpCmdLine = GetCommandLine WinMain(hInstance, NULL, lpCmdLine, SW_SHOWDEFAULT) ExitProcess(0)