CApp::CApp()
{
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"game", NULL };
RegisterClassEx( &wc );
// Create the application''s window.
HWND hWnd = CreateWindow( "game", "Matt''s Game",
WS_OVERLAPPEDWINDOW, 100, 100, 300, 300,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
_ASSERT(hWnd);
Thanks
Can't create window!
I''m trying to create a window inside a class constructor using a message callback procedure that is a static member of that class. For some reason I can not determine, CreateWindow is returning null!
Here''s my source. Any idea what''s going on?
i''m assuming CApp is your main app class, so put that code in BOOL InitInstance instead, i don''t think mfc initilizes everything until then.
quote:Original post by Xtremehobo
"1400 Invalid window handle. ERROR_INVALID_WINDOW_HANDLE"
Hmmm. Well the only window handle you pass the CreateWindow is when you call GetDesktopWindow. Try it with NULL in place and see what happens.
Still not working. I changed my code to this:
I'm getting error 1813 (The specified resource type cannot be found in the image file. ERROR_RESOURCE_TYPE_NOT_FOUND)
[edited by - Xtremehobo on October 7, 2003 7:03:50 PM]
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, hInstance, NULL, NULL, NULL, NULL, "D3D Tutorial 1", NULL }; if(!(RegisterClassEx( &wc ))) MessageBox(NULL,"Could not register window class","Game",MB_OK); // Create the application's window HWND hWnd = CreateWindow( "D3D Tutorial 1", "D3D Tutorial 1", WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL ); _ASSERTE(hWnd); DWORD error = GetLastError(); char stuff[255]; sprintf(stuff,"error code: %i",error); MessageBox(NULL,stuff,"test",MB_OK);
I'm getting error 1813 (The specified resource type cannot be found in the image file. ERROR_RESOURCE_TYPE_NOT_FOUND)
[edited by - Xtremehobo on October 7, 2003 7:03:50 PM]
I''m not even getting a window though. CreateWindow is failing and returning NULL into my hwnd variable.
damn.. i was editing, and my comp froze so i started clicking all over so my post got deleted ala "click here if you double posted".. sorry
anyway, what i meant was if you return a bad number in one of your handlers, ie WM_NCCREATE, CreateWindowEx() could fail, giving a null handle, which is probably your error. check your pre-creation messages. I think i had a problem with wm_nccreate, and i never figured it out. I solved it by returning DefWindowProc() after doing my SetWindowLongPtr() thing.
anyway, what i meant was if you return a bad number in one of your handlers, ie WM_NCCREATE, CreateWindowEx() could fail, giving a null handle, which is probably your error. check your pre-creation messages. I think i had a problem with wm_nccreate, and i never figured it out. I solved it by returning DefWindowProc() after doing my SetWindowLongPtr() thing.
I'm returning DefWindowProc now and it's not returning null! However, GetLastError is now giving me "The specified resource type cannot be found in the image file." and I still see no window
EDIT: nevermind, forgot to add ShowWindow! Thanks for the help
[edited by - Xtremehobo on October 7, 2003 8:24:07 PM]
EDIT: nevermind, forgot to add ShowWindow! Thanks for the help
[edited by - Xtremehobo on October 7, 2003 8:24:07 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement