I found one of the O2 examples specifically demos RegisterClassEx. It works with MinWin.inc
/examples/RegisterClassEx.o2bas
$ filename "t.exe"
'#include "..\..\inc\RTL32.inc"
#include "../../inc/MinWin.inc"
s=error()
'
if s then
print s
end
end if
% ID_Timer 3000
% Interval 100
'==================
'GLOBAL DEFINITIONS
'==================
sys inst,hdc
sys xmax,ymax,r,idx,idy,xball,yball
r =15 : idx =5 : idy=5 : xball=200 : yball=100
dim as rect crect 'for WndProc
'--------------------------------------------------------------------------------------------------------------------------
function WndProc ( byval hWnd as long, byval wMsg as long, byval wParam as long, byval lparam as long ) as long callback
'==========================================================================================================================
static as sys count=0, refreshes=0, hdc, keycode, charcode
static as String txt
static as PaintStruct Paintst
'==========
select wMsg
'==========
'--------------
case WM_CREATE
'=============
hTimer = SetTimer hWnd, ID_Timer, 50, 0
GetClientRect hWnd,@cRect
'--------------
case WM_TIMER
'=============
InvalidateRect hwnd,@crect,1
'--------------
case WM_DESTROY
'===============
KillTimer(hWnd,ID_TIMER)
PostQuitMessage 0
'------------
case WM_PAINT
'============
'TEXT
'http://msdn.microsoft.com/en-us/library/dd144821(v=VS.85).aspx
'DRAWING AND PAINTING
'http://msdn.microsoft.com/en-us/library/dd162760(v=VS.85).aspx
hDC=BeginPaint hWnd,@Paintst
GetClientRect hWnd,@cRect
'style
'0x20 DT_SINGLELINE
'0x04 DT_VCENTER
'0x01 DT_CENTER
'0x25
SetBkColor hdc,white
SetTextColor hdc,blue
'
txt="Key Code 0x" hex(keycode) " Char Code 0x" hex(charcode)
'
DrawText hDC,*txt,-1,@cRect,0x25
EndPaint hWnd,@Paintst
ValidateRect hwnd,@crect
'-----------
case WM_CHAR
'===========
charcode=wparam
'--------------
case WM_KEYDOWN
'==============
keycode=wParam : charcode=0
if wParam=27 then SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
'--------
case else
'========
function=DefWindowProc hWnd,wMsg,wParam,lParam
end select
end function ' WndProc
'----------------------------------------------------------------------
Function WinMain(sys inst, prevInst,zstring* cmdline, sys show) as long
'======================================================================
WNDCLASSEX wc
MSG wm
string ClassName="Demo", MenuName="Menu"
sys hwnd, wwd, wht, wtx, wty, tax
'
wc.cbSize=sizeof WNDCLASSEX
wc.style = CS_HREDRAW or CS_VREDRAW
wc.lpfnWndProc = @WndProc
wc.cbClsExtra =0
wc.cbWndExtra =0
wc.hInstance =inst
wc.hIcon=LoadIcon 0, IDI_APPLICATION
wc.hCursor=LoadCursor 0,IDC_ARROW
wc.hbrBackground = GetStockObject WHITE_BRUSH
wc.lpszMenuName = strptr MenuName
wc.lpszClassName = strptr ClassName
wc.hIconSm=0
'
a=RegisterClassEx (@wc)
'
Wwd = 340 : Wht = 160
Tax = GetSystemMetrics SM_CXSCREEN
Wtx = (Tax - Wwd) /2
Tax = GetSystemMetrics SM_CYSCREEN
Wty = (Tax - Wht) /2
hwnd = CreateWindowEx 0,wc.lpszClassName,"OXYGEN BASIC",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
ShowWindow hwnd,SW_SHOW
UpdateWindow hwnd
'
sys bRet
'
do while bRet := GetMessage (@wm, 0, 0, 0)
if bRet = -1 then
'show an error message
exit while
else
TranslateMessage @wm
DispatchMessage @wm
end if
wend
End Function
'=========
'MAIN CODE
'=========
dim cmdline as asciiz ptr,inst as long
@cmdline=GetCommandLine
inst=GetModuleHandle 0
'
'WINDOWS
'-------
'
WinMain inst,0,cmdline,SW_NORMAL
end
type WNDCLASSEX
int cbSize
int Style
sys lpfnwndproc
int cbClsextra
int cbWndExtra
sys hInstance
sys hIcon
sys hCursor
sys hbrBackground
sys lpszMenuName
sys lpszClassName
sys hIconSm
end type
PS:
TranslateMessage does not have an A or W specifier, unlike DispatchMessage