I am really amazed. If all of this is correct, I will start programming in Unicode.
The HelloWin app:
$ filename "HelloWin.exe"
'uses rtl32
'uses rtl64
uses corewin
! PlaySoundW lib "winmm.dll"
% DT_SINGLELINE = &H20
% DT_CENTER = &H1
% DT_VCENTER = &H4
% SND_ASYNC 0x0001 ' play asynchronously
% SND_FILENAME 0x20000 ' name is file name
sys hInstance = GetModuleHandleW (NULL)
int iCmdShow = SW_SHOW
function WinMain () as sys
wstring szAppName = L"HelloWin"
sys hwnd
MSG msg
WNDCLASS wc
wc.style = CS_HREDRAW or CS_VREDRAW
wc.lpfnWndProc = @WndProc
wc.cbClsExtra = 0
wc.cbWndExtra = 0
wc.hInstance = hInstance
wc.hIcon = LoadIconW (NULL, IDI_APPLICATION)
wc.hCursor = LoadCursorW (NULL, IDC_ARROW)
wc.hbrBackground = GetStockObject (WHITE_BRUSH)
wc.lpszMenuName = NULL
wc.lpszClassName = strptr szAppName
if not RegisterClassW (&wc) then
MessageBoxW (NULL, L"Cannot RegisterClass wc",
szAppName, MB_ICONERROR)
return 0
end if
hwnd = CreateWindowExW (0,
szAppName, // window class name
L" The Hello Program", // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) // creation parameters
ShowWindow (hwnd, iCmdShow)
UpdateWindow (hwnd)
while GetMessageW (&msg, NULL, 0, 0)
TranslateMessage (&msg)
DispatchMessageW (&msg)
wend
end function
function WndProc (sys hwnd, uint message, sys wParam, sys lParam) as sys callback
sys hdc
PAINTSTRUCT ps
RECT rct
select case message
case WM_CREATE
PlaySoundW (L"c:/windows/media/tada.wav", NULL, SND_FILENAME or SND_ASYNC)
case WM_PAINT
hdc = BeginPaint (hwnd, &ps)
GetClientRect (hwnd, &rct)
DrawTextW (hdc, L"Hello World from Oxygen Basic!", -1, &rct,
DT_SINGLELINE or DT_CENTER or DT_VCENTER)
EndPaint (hwnd, &ps)
case WM_DESTROY
PostQuitMessage (0)
end select
return DefWindowProcW (hwnd, message, wParam, lParam)
end function
WinMain()
Edit: Modified GetModuleHandle to GetModuleHandleW