Code:
defint a-z
option explicit
option private
'$include once:'win\kernel32.bi'
'$include once:'win\user32.bi'
'$include once:'win\gdi32.bi'
'$include once:'win\commctrl32.bi'
dim shared ApphInstance as long
dim shared chkhWnd as long
declare function WinMain ( byval hInstance as long, _
byval hPrevInstance as long, _
szCmdLine as string, _
byval iCmdShow as integer ) as integer
' Entry point
end WinMain( GetModuleHandle( null ), null, Command$, SW_NORMAL )
defint a-z
function WndProc ( byval hWnd as long, _
byval message as long, _
byval wParam as long, _
byval lParam as long ) as integer
dim rct as RECT
dim pnt as PAINTSTRUCT
dim hDC as long
WndProc = 0
select case ( message )
case WM_CREATE
chkhWnd = CreateWindowEx( 0, _
"BUTTON", _
"Check1", _
WS_VISIBLE or WS_CHILD or BS_AUTOCHECKBOX, _
5, _
5, _
100, _
25, _
hWnd, _
null, _
ApphInstance, _
null )
return 0
exit function
case WM_CTLCOLORSTATIC
SetBkMode(wParam, 1)
SetBkColor(wParam, RGB(246,235,206))
SetTextColor(wParam, RGB(255,255,255))
return CreateSolidBrush(0)
exit function
case WM_DESTROY
PostQuitMessage 0
exit function
end select
WndProc = DefWindowProc( hWnd, message, wParam, lParam )
end function
defint a-z
function WinMain ( byval hInstance as long, _
byval hPrevInstance as long, _
szCmdLine as string, _
byval iCmdShow as integer ) as integer
dim wMsg as MSG
dim wcls as WNDCLASS
dim szAppName as string
dim hWnd as unsigned long
ApphInstance=hInstance
WinMain = 0
szAppName = "HelloWin"
InitCommonControls()
with wcls
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra = 0
.cbWndExtra = 0
.hInstance = hInstance
.hIcon = LoadIcon( null, IDI_APPLICATION )
.hCursor = LoadCursor( null, IDC_ARROW )
.hbrBackground = GetStockObject( WHITE_BRUSH )
.lpszMenuName = null
.lpszClassName = strptr( szAppName )
end with
if ( RegisterClass( wcls ) = false ) then
MessageBox null, "This program requires Windows NT!", szAppName, MB_ICONERROR
exit function
end if
hWnd = CreateWindowEx( 0, _
szAppName, _
"The Hello Program", _
WS_OVERLAPPEDWINDOW, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
CW_USEDEFAULT, _
null, _
null, _
hInstance, _
null )
ShowWindow hWnd, iCmdShow
UpdateWindow hWnd
while ( GetMessage( wMsg, null, 0, 0 ) <> false )
TranslateMessage wMsg
DispatchMessage wMsg
wend
WinMain = wMsg.wParam
end function