12-16-2004, 05:05 AM
Here is my example of using comctl32 to display calendar object in a window. It's require libcomctl32.a to compile this source code. I use old dev-cpp 4.0 libcomctl32.a file (dated 1999), then copy it into FB's \lib directory and it works okay with FB.
It has been fun for me so far playing with FB. I would try experimenting with other win32 coding using the fantastic FB compiler.
cheers,
zydon.
Code:
'' filename: wincal.bas
'$include:'kernel32.bi'
'$include:'user32.bi'
const null = 0
const true = -1
const false = 0
''
'' kernel32 Additon
''
declare sub ExitProcess _
lib "kernel32" _
alias "ExitProcess" _
(lpModuleName as integer)
''
'' Comctrl32 Addition :: Require libcomctl32.a
''
const ICC_DATE_CLASSES = 256
type INITCOMMONCONTROLSEX
dwSize as integer
dwICC as integer
end type
declare sub InitCommonControlsEx _
lib "comctl32" _
alias "InitCommonControlsEx" _
(byval lpUdt as long)
dim shared szCalClass as string
szCalClass = "SysMonthCal32"
dim shared hCal as long
dim iccx as INITCOMMONCONTROLSEX
iccx.dwSize = len( iccx )
iccx.dwICC = ICC_DATE_CLASSES
InitCommonControlsEx @iccx
''
'' Window Procedure Handler
''
function WndProc ( byval hWnd as long, _
byval uMsg as long, _
byval wParam as long, _
byval lParam as long ) as integer
WndProc = 0
select case ( uMsg )
case WM_CREATE
hCal = CreateWindowEx( 0, _
szCalClass, "", _
WS_CHILD or _
WS_VISIBLE, _
2, 2, 200, 160, _
hWnd, null, _
hInstance, null )
case WM_KEYDOWN
if( (wParam and &hff) = 27 ) then
PostMessage hWnd, WM_CLOSE, 0, 0
end if
case WM_DESTROY
PostQuitMessage 0
exit function
end select
WndProc = DefWindowProc( hWnd, uMsg, wParam, lParam )
end function
''
'' Program entry
''
dim wMsg as MSG
dim wcls as WNDCLASS
dim hWnd as unsigned long
dim hInstance as long
dim szAppName as string
szAppName = "WinCal32"
wcls.style = CS_HREDRAW or CS_VREDRAW
wcls.lpfnWndProc = @WndProc()
wcls.cbClsExtra = 0
wcls.cbWndExtra = 0
wcls.hInstance = hInstance
wcls.hIcon = LoadIcon( null, IDI_APPLICATION )
wcls.hCursor = LoadCursor( null, IDC_ARROW )
wcls.hbrBackground = 6 ' default color
wcls.lpszMenuName = null
wcls.lpszClassName = sadd( szAppName )
if ( RegisterClass( wcls ) = false ) then
MessageBox null, "Failed to register wcls!", _
szAppName, MB_ICONERROR
Goto Done
end if
hWnd = CreateWindowEx( 0, _
szAppName, "Calendar Demo [ESC to Quit]", _
WS_CLIPCHILDREN or _
WS_DLGFRAME or WS_BORDER or _
WS_VISIBLE, _
200, 200, 210, 190, _
null, null, hInstance, null )
''
'' messages loop
''
Again:
if ( GetMessage( wMsg, null, 0, 0 ) = false ) _
then goto Done
TranslateMessage wMsg
DispatchMessage wMsg
Gosub Again
Done:
ExitProcess 0
It has been fun for me so far playing with FB. I would try experimenting with other win32 coding using the fantastic FB compiler.
cheers,
zydon.