Mar 16, 2011 at 8:55am UTC
My class makes a Initialize(int iCmdShow) function to hide some of the dirty work which winmain has to do, and its code is this:
BOOL GameEngine::Initialize(int iCmdShow)
{
WNDCLASSEX wndclass;
// Create the window class for the main window
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = m_hInstance;
wndclass.hIcon = LoadIcon(m_hInstance,
MAKEINTRESOURCE(GetIcon()));
wndclass.hIconSm = LoadIcon(m_hInstance,
MAKEINTRESOURCE(GetSmallIcon()));
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = m_szWindowClass;
Is there any reason why I have give the function the iCmdShow parameter
Mar 16, 2011 at 10:02am UTC
I mean, i cant see anywhere where i put the parameter to use.
Mar 16, 2011 at 10:11am UTC
First, I'm sure you have been asked before, Please use code tags to post code.
[co de] Your code here [/co de]
Second, "Is there any reason why I have give the function the iCmdShow parameter ", It's your class, your design, how are we meant to answer that?
Last edited on Mar 16, 2011 at 10:12am UTC
Mar 16, 2011 at 10:24am UTC
I havnt been asked that actually, but i will from now on :)
Haha, fair enough.
Mar 16, 2011 at 10:38am UTC
Are you making a class that implements the basic tasks of registering the window class, creating a window, and dispatching window messages? The third task would be a little tricky.
Mar 16, 2011 at 11:21am UTC
Okay, a quick answer to the question would be; no, you don't need
int iCmdShow
as a parameter to
GameEngine::Initialize()
.
You would have a member function like:
1 2 3 4
BOOL ShowWindow(int nCmdShow) const
{
return ::ShowWindow(m_hWnd, nCmdShow);
}
(assuming your class stores a HWND in m_hWnd)
Edit:
I would look at changing
Initialize() to something like:
1 2 3 4 5 6 7
void GameEngine::GetWndClassEx(WNDCLASSEX & wc)
{
memset(&wc,0,sizeof (wc) );
wc.cbSize = sizeof (WNDCLASSEX);
// and so on
}
Last edited on Mar 16, 2011 at 11:38am UTC