Here is my first example using RC08
I prefer
DIM As VarType varname
rather than
Dim varname As VarType
primarily because of all the c/c++ code I've ported over the years.
Copy paste the c/c++ code and just add the Dim As
I do like the way Jose starts his apps so I borrowed :)
James
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
#define unicode
#Include Once "windows.bi"
#Include Once "Afx/CWindow.inc"
Using Afx.CWindowClass
'------------------------------------------------------------------------------
'I like my PowerBASIC macros
#define CBCTLMSG HIWORD(wParam)
#define CBCTL LOWORD(wParam)
#define CBHNDL hWnd
#define CBHWND hWnd
#define CBLPARAM lParam
#define CBWPARAM wParam
#define CBMSG uMsg
'------------------------------------------------------------------------------
Declare Function WinMain (Byval hInstance As HINSTANCE, _
Byval hPrevInstance As HINSTANCE, _
Byval szCmdLine As ZSTRING PTR, _
Byval nCmdShow As LONG) AS LONG
END WinMain(GetModuleHandle(""), NULL, COMMAND(), SW_NORMAL)
'========================================================================================
' Window procedure
' ========================================================================================
Function WndProc (Byval hWnd As HWND, Byval uMsg As UINT, Byval wParam As WPARAM, Byval lParam As LPARAM) As LRESULT
Select Case CBMSG
Case WM_COMMAND
Select Case CBCTL
Case IDCANCEL
' // If ESC key pressed, close the application sending an WM_CLOSE message
If CBCTLMSG = BN_CLICKED THEN
SendMessage CBHWND, WM_CLOSE, 0, 0
Exit Function
End If
End Select
Case WM_DESTROY
PostQuitMessage(0)
Exit Function
End Select
Function = DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function
'==============================================================================
Function WinMain (Byval hInstance As HINSTANCE, _
Byval hPrevInstance As HINSTANCE, _
Byval szCmdLine As ZSTRING PTR, _
Byval nCmdShow As LONG) AS LONG
Dim As CWindow pWindow
Dim As HWND hwndMain = pWindow.Create(NULL,"CWindow Test",@WndProc)
pWindow.SetClientSize(500,320)
pWindow.Center
Function = pWindow.DoEvents(nCmdShow)
End Function
'==============================================================================
With these defines you always have to use hWnd, wParam and lParam in the callback. If you, for example, change hWnd to hWin, it will fail.
Paul is going to use C-like message crackers.
Yes, I am using message crackers in my code now. I just needed to modify the windowsx.bi include file that was not correctly translated in the FB distribution. Seems to be working pretty well so far.