|
-
November 27th, 2004, 09:59 PM
#1
CreateWindow failing?
I must be stupid, I don't know why this isn't working:
Code:
//====================================================================================
/*
|| Creates a window for the game
|| Returns NULL if failed, the window handle if successful.
*/
HWND DirectX_Utils::GameWindowCreate(string WindowTitle)
{
WNDCLASS CS;
CS.cbClsExtra = 0;
CS.cbWndExtra = 0;
CS.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
CS.hIcon = NULL;
CS.hCursor = NULL;
CS.hInstance = GlobalInstance;
CS.lpfnWndProc = WindowProcedure;
CS.lpszClassName = "GameAppClass";
CS.lpszMenuName = 0;
CS.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_OWNDC;
if(!RegisterClass(&CS))
return NULL;
return (MainWindow = CreateWindow("GameAppClass", WindowTitle.c_str(), WS_POPUP | WS_VISIBLE,
100, 100, 300, 300, NULL, NULL, GlobalInstance, NULL));
}
CreateWindow returns NULL!
GlobalInstance and WindowProcedure are both private members of my class, which are initialized appropriately at construction.
MainWindow is a private member also which receives the handle to the window.
-
November 28th, 2004, 03:47 AM
#2
Re: CreateWindow failing?
What is WindowProcedure? Is this window procedure a member of your class? You can't use a function pointer to a member of your class for use as a window procedure.
-
November 28th, 2004, 04:00 AM
#3
Re: CreateWindow failing?
Well...as usual...what does 'GetLastError()' return? For further information take a look at the following FAQ...
-
November 28th, 2004, 07:49 AM
#4
Re: CreateWindow failing?
Have you declared the function "WindowProcedure" as follow ?
LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch(uiMsg)
...
...
return DefWindowProc(...);
}
If yes, try this 2 way:
CreateWindow("GameAppClass", WindowTitle.c_str(), WS_POPUP | WS_VISIBLE,
100, 100, 300, 300, NULL, NULL, GlobalInstance, (void*)this);
or
CreateWindow("GameAppClass", WindowTitle.c_str(), WS_POPUP | WS_VISIBLE,
100, 100, 300, 300, NULL, NULL, GetModuleHandle(NULL), NULL;
I don't kwno how your complete class is, maybe these can cause an error...
EDIT:
I have forgotten:
are you creating a fullscreen window or a window-mode one ? If window-mode, you must specify WS_CLIPCHILDREN | WS_CLIPSIBLINGS flags besides WS_POPUP | WS_VISIBLE...
If you're creating a fullscreen window, the probrem can rise becouse you choose a resolution that your hardware/system doesn't supports
Also I recommend you to use CreateWindowEx(....) in the future...
Last edited by Elementer; November 28th, 2004 at 07:55 AM.
-
November 28th, 2004, 11:27 AM
#5
Re: CreateWindow failing?
Ooops.... I didn't put this at the end of my Window Proc:
return DefWindowProc(hwnd, msg, wparam, lparam);
*slaps himself*
Last edited by MrDoomMaster; November 28th, 2004 at 11:30 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|