Anyone? I really need to know if this is the proper way to do this. Well here are my constructors for CWindow: You can see the cleaner looking code since the BB is nice at: http://www.gamedev.net/community/for...topic_id=81529
Code:
CWindow::CWindow(const HINSTANCE& hInstance,char* pszClassName, const
WNDPROC WndProc ): hInst(hInstance), bInitFail(false), pszCName
(pszClassName){ wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0;
wndClass.hbrBackground = (HBRUSH)COLOR_WINDOW;
wndClass.hInstance = hInstance; wndClass.hCursor =
LoadCursor(NULL,IDC_ARROW); wndClass.hIcon = LoadIcon
(NULL,IDI_APPLICATION); wndClass.hIconSm = LoadIcon
(NULL,IDI_APPLICATION); wndClass.lpszClassName = pszClassName;
wndClass.lpszMenuName = NULL; wndClass.style =
CS_OWNDC | CS_VREDRAW | CS_HREDRAW; if(WndProc) {
wndClass.lpfnWndProc = WndProc; }
else { wndClass.lpfnWndProc = &(this-
>WindowProc); } if(!RegisterClassEx(&wndClass)) {
MessageBox(NULL,"ERROR IN APPLICATION STARTUP","Error In
Registering Window Class",MB_OK); bInitFail = true; }}
CWindow::CWindow(const HINSTANCE& hInstance, const UINT& style, const
HBRUSH& hBackground, const
HICON& hIconSmall, const HICON& hIconLarge, const HCURSOR& Cursor,
char* pszClassName, const
WNDPROC WndProc): hInst(hInstance), bInitFail(false), pszCName
(pszClassName){ wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0;
wndClass.hbrBackground = (HBRUSH)hBackground; wndClass.hIcon
= hIconLarge; wndClass.hIconSm = hIconSmall;
wndClass.hInstance = hInstance; wndClass.hCursor =
Cursor; wndClass.lpszClassName = pszClassName;
wndClass.lpszMenuName = NULL; wndClass.style = style;
if(WndProc) { wndClass.lpfnWndProc =
WndProc; } else { wndClass.lpfnWndProc = &(this-
>WindowProc); } if(!RegisterClassEx(&wndClass)) {
MessageBox(NULL,"ERROR IN APPLICATION STARTUP","Error In
Registering Window Class",MB_OK); bInitFail = true; }}
Both of these take a WNDPROC param that is by default set to NULL in their definition. Then in my derived class CAppWindow I pass it like this:
Code:
CAppWindow::CAppWindow(const HINSTANCE& hInstance, char*
pszClassName): CWindow(hInstance,pszClassName,&this->WndProc){}
CAppWindow::CAppWindow(const HINSTANCE& hInstance, const UINT& style,
const HBRUSH& hBackground,
const HICON& hIconSmall,const HICON& hIconLarge, const HCURSOR&
hCursor, char* pszClassName):
CWindow(hInstance, style, hBackground, hIconSmall, hIconLarge,
hCursor, pszClassName, &this->WndProc){}
Here you can see how Im passing the addres of the derived class's WndProc. But it generates the warning:
C:\My Documents\Projects\CBWindow\CAppWindow.cpp(4) : warning C4355: 'this' : used in base member initializer list
Is this the proper way of doing this?