[SOLVED] CreateWindowEx problem

Started by
5 comments, last by F-Kop 17 years, 11 months ago
After CreateWindowEx fails, it gave me error code 1400, which is "invalid window handle". Why would it be that error if the window handle (for the parent, which is the only thing it can possibly be talking about) is NULL? I'm not making a child window. Any help is appreciated. [Edited by - F-Kop on May 7, 2006 5:15:44 PM]
---------------------------------Upon thine ass shall I bust but a single cap.
Advertisement
Post some code. Are you checking GetLastError before CreateWindowEx so you know it's not set "early"? I think you can SetLastError(0); before CreateWindowEx too. But posting some code would likely help.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

also, what type of window class are you using? control classes must have a parent window. and if i recall right, even dialogs created from CWEx, must have a valid parent window handle supplied to CWEx.
Are there any child controls on the window which you try to create in WM_CREATE?

What does your WindowProc look like? Are you trying to make a class wrapper?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

It is a class wrapper. It worked fine for my CWnd class, but not CFrameWnd.

if( !( m_handle = CreateWindowEx( styleEx, className, text, style,	box.x, box.y, box.w, box.h, ( parent? parent->m_handle : NULL ),	( menu? menu->m_handle : NULL ), g_inst, NULL ) ) )	return FALSE;


styleEx is NULL, className is "CFrameWnd", which was registered successfully, text is "blah", style is WS_OVERLAPPEDWINDOW, box is the coordinates and size, (which are all CW_USEDEFAULT), parent is NULL, menu is NULL, and g_inst is the instance returned by GetModuleHandle.

The error code says "invalid window handle". The only window handle involved is the parent window, which is NULL in this case, and I'm not creating a child window.
---------------------------------Upon thine ass shall I bust but a single cap.
Nothing wrong from this part. Again, what does the window proc look like?

Note that the window proc will have to process some messages during CreateWindow(Ex) already. Even if the class handler is not completely initialized the messages need to be passed on to at least DefWindowProc. My guess is that the HWND passed to your window proc is not passed on correctly.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Yeah it was a wndproc problem, but it's solved now.
---------------------------------Upon thine ass shall I bust but a single cap.

This topic is closed to new replies.

Advertisement