General Method

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
I mean, i cant see anywhere where i put the parameter to use.
closed account (z05DSL3A)
First, I'm sure you have been asked before, Please use code tags to post code.
[code] Your code here [/code]

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
I havnt been asked that actually, but i will from now on :)

Haha, fair enough.
closed account (z05DSL3A)
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.
yep
closed account (z05DSL3A)
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
:D
closed account (z05DSL3A)
I wrote:
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


This lead me to start:
http://www.cplusplus.com/forum/articles/38748/
Topic archived. No new replies allowed.