[SOLVED] CreateWindowEx problem
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]
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.
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?
What does your WindowProc look like? Are you trying to make a class wrapper?
It is a class wrapper. It worked fine for my CWnd class, but not CFrameWnd.
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement