none
CreateWindow API is not working on VS2015.. RRS feed

  • Question

  • Hello,

    We are using CreateWindow() API which was working correctly on VS2012 before upgrading to VS2015. After upgrading to VS2015 CreateWindow API is returning null HWND.

    We are calling AtlAxWinInit() before CreateWindow() API as shown below.

    Eg:

    // Code on VS2012 which is working correctly and failing on VS2015.

    CreateControl()

    {

          BOOL res = AtlAxWinInit();         // successfully return true..

          // Below API successfully return HWND on VS2012 level.

          HWND hwndChild =   CreateWindow(_T("AtlAxWin110"),
                                                                    _T("test"),
                                                                    WS_CHILD|WS_VISIBLE,
                                                                    0,0,0,0,
                                                                    hwnd,NULL,
                                                                   ::GetModuleHandle(NULL),
                                                                   NULL);

    }

    As per VS2015 we changed class name to "AtlAxWin140" still API is failing.

    CreateControl()

    {

          BOOL res = AtlAxWinInit();         // successfully return true..

          // For VS2015 we changed class name to "AtlAxWin140" still API is returning null HWND.

          HWND hwndChild =   CreateWindow(_T("AtlAxWin140"),
                                                                    _T("test"),
                                                                    WS_CHILD|WS_VISIBLE,
                                                                    0,0,0,0,
                                                                    hwnd,NULL,
                                                                   ::GetModuleHandle(NULL),
                                                                   NULL);

    }

    I also checked GetLastError() after CreateWindow calll; it is returning 1407 error code which is ERROR_CANNOT_FIND_WND_CLASS :Cannot find window class.

    Could you please help me to resolve this..

    Thanks..


    • Edited by Dnyandev Friday, August 31, 2018 6:29 AM update error code
    Thursday, August 30, 2018 11:21 AM

All replies

  • It is "AtlAxWin"
    Thursday, August 30, 2018 12:12 PM
  • Thanks for your reply. I tried with "AtlAxWin" it is not working.

    Thursday, August 30, 2018 12:35 PM
  • When I tried the posted code with VS2015 CreateWindow returned NULL, GetLastError was ERROR_SUCCESS, and ATL had written error messages in the Output pane --

    c:\program files\microsoft visual studio 14.0\vc\atlmfc\include\atlhost.h(2498) : atlTraceControls - Control creation failed for 'test'
    c:\program files\microsoft visual studio 14.0\vc\atlmfc\include\atlhost.h(2499) : atlTraceControls - Error code: 0x800401f3 - Invalid class string

    Edit :

    Window creation failed because the ATL Window procedure returned -1 from WM_CREATE

    • Edited by RLWA32 Thursday, August 30, 2018 12:59 PM added comment
    Thursday, August 30, 2018 12:53 PM
  • Thanks for your reply. I tried with "AtlAxWin" it is not working.

    This works for me, VS 2015 on Windows 10 :

    HINSTANCE hATLDLL;
    typedef BOOL(__stdcall *PAAWI)(void);
    PAAWI pAtlAxWinInit;
    hATLDLL = LoadLibrary(_T("atl.dll"));
    pAtlAxWinInit = (PAAWI)GetProcAddress(hATLDLL, "AtlAxWinInit");
    if (pAtlAxWinInit)
    	pAtlAxWinInit();
    
    HWND hwndChild = CreateWindow(_T("AtlAxWin"),
    	_T("test"),
    	WS_CHILD | WS_VISIBLE,
    	0, 0, 0, 0,
    	hWnd, NULL,
    	::GetModuleHandle(NULL),
    	NULL);

    • Proposed as answer by Baron Bi Thursday, September 6, 2018 2:17 AM
    Thursday, August 30, 2018 1:09 PM
  • Did you ever get by this issue?

    I am having the same issue with code I'm attempting to upgrade from VS2008 to VS2015.

    Thanks.

    Saturday, March 9, 2019 7:54 PM