Createwindow Error 1400
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about createwindow returns 1400 Stack Overflow the company Business Learn more about hiring developers or posting ads with
Getlasterror 1400
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why does uninitialised return value cause Invalid Window Handle err in CreateWindowEx? up vote -2 down vote favorite 2 Edit- Added code to do with m_hWndClient and the WndProc that were not originally included. In an attempt to be brief I had incorrectly assumed it was unrelated. After the following is run HWND m_hWndFrame; HWND m_hWndClient; // added in Edit2 ... m_hWndFrame = CreateWindowEx(...) m_hWndFrame is NULL and GetLastError gives "Error 1400 - Invalid Window Handle" but this works fine: HWND m_hWndFrame = NULL; HWND m_hWndClient = NULL; // added in Edit2 ... m_hWndFrame = CreateWindowEx(...) My WndProc looks like this: LRESULT CALLBACK ProgramManager::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { CLIENTCREATESTRUCT clientCreate; HINSTANCE hInstance = GetModuleHandle(NULL); RECT clientRect; switch (uMsg) { case WM_CREATE: clientCreate.hWindowMenu = NULL; clientCreate.idFirstChild = IDM_FIRSTCHILD ; GetClientRect(hwnd,&clientRect); s_instance->m_hWndClient = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT ("MDICLIENT"), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, clientRect.right, clientRect.bottom, hwnd, (HMENU)ID_MDI_CLIENT, hInstance, (LPVOID)&clientCreate); return 0 ; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefFrameProc(hwnd,m_hWndClient,uMsg,wParam,lParam); } My project now works (after much hair-tearing) but I don't understand why initialising a variable that is only used to hold a return value should matter. Obviously assuming that a variable is NULL or 0 without initialising and then using or testing the contents (eg if (!m_unitialisedVariable)) is going to end in disaster but why should it matter in this instance? There is no requirement for m_hWndFrame to contain anything in particular before calling 'CreateWindowEx' (at least according to the Help in VS2010) so why should it affect the outcome of 'CreateWindowEx'? c++ windows winapi createwindowex share|improve this question edited May 22 '13 at 21:19 asked May 21 '13 at 23:44 Malorion 318138 2 It is impossible to know for certain without seeing
Development > Visual C++ Question 0 Sign in to vote Hi, I am using WTL to create a modleless child window with code: HWND hwnd = Dialog->Create(m_hWnd,NULL) And there is two point I can't figure it out. The first is it is failed to create the child window, even though the parent window handle is valid. I got a return error 1400 which means invalid window handle. The second thing is I can see in my log that OnDestroy function of the child window is called before I call Create function to http://stackoverflow.com/questions/16681303/why-does-uninitialised-return-value-cause-invalid-window-handle-err-in-createwin create the window, this is out of my mind, can it be happened in theory? This weird thing is only happen on one computer and I can't find the reason in this computer, have somebody met this problem before? Any suggestion or hint will be very appreciated. Regards. Monday, December 30, 2013 11:47 AM Reply | Quote All replies 0 Sign in to vote ReferWTL for MFC Programmers https://social.msdn.microsoft.com/Forums/vstudio/en-US/de092627-2491-4005-86bd-b058f59ebdd6/error-1400-when-call-create?forum=vcgeneral The code snippet you posted seems MFC. The Create() returns BOOL. Not HWND.Thanks, Renjith V R Monday, December 30, 2013 1:45 PM Reply | Quote 0 Sign in to vote Hi,Renjth, Its prototype is in atlwin.h as below: // modeless dialogs HWND Create(HWND hWndParent, LPARAM dwInitParam = NULL) { ATLASSUME(m_hWnd == NULL); AtlWinModule.AddCreateWndData(&m_thunk.cd, (CDialogImplBaseT< TBase >*)this); #ifdef _DEBUG m_bModal = false; #endif //_DEBUG HWND hWnd = AtlAxCreateDialog(_AtlBaseModule.GetResourceInstance(), MAKEINTRESOURCE(static_cast
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire https://www.experts-exchange.com/questions/20833912/CreateWindowEx-returns-error-1400.html for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > CreateWindowEx returns error 1400 Want to Advertise Here? Solved CreateWindowEx returns error 1400 Posted on 2003-12-23 MS Development-Other Web Components 1 Verified Solution 6 Comments 2,026 Views Last Modified: 2013-12-04 error 1400 I've looked at MSDN, and the 4 things they say to look at for CreateWindowEx failing as far as I know are false. None of the params are invalid. I highly doubt the system class is registered when I've changed the class to different names (hope I'm understanding that one right). I'm not sure if the 3rd one is true or not, this createwindow error 1400 is a plugin for AstonShell, but then I look at another plugin I've made with the EXACT same code for CreateWindowEx and only this one errors. And then WM_CREATE and NCCREATE are handled by DefWindowProc. Are there any other things that can cause CreateWindowEx to return NULL? I've tried everything. If anyone wants to see the code, then I'll paste it. 0 Question by:Veratil Facebook Twitter LinkedIn Google LVL 48 Best Solution byAlexFM Open 0-points question in Commity support area: http://www.experts-exchange.com/Community_Support/ Provide link to this question and ask to refund your points. If you want to give me part of points, Go to Solution 5 Comments LVL 48 Overall: Level 48 MS Development-Other 12 Web Components 3 Message Expert Comment by:AlexFM2003-12-23 Please show your code. Do you mean that GetLastError is 1400? This is "Invalid window handle". Possibly HWND hWndParent parameter is wrong. 0 Message Author Comment by:Veratil2003-12-23 void WINAPI InitGlobalModule(const PAstonData AstonData) { WNDCLASS WindowClass; if (AstonData->cbsize < sizeof(TAstonData)) return; RtlMoveMemory(&AData, AstonData, sizeof(TAstonData)); RtlZeroMemory(&WindowClass, sizeof(WNDCLASS)); WindowClass.style = CS_HREDRAW | CS_VREDRAW; WindowClass.hCursor = LoadCursor(0, IDC_ARROW); WindowClass.hInstance =