CreateWindow could not find window class

270 Views Asked by At

Am using CreateWindow() API which was working correctly on VS2015 before upgrading to VS2019. After upgrading to VS2015 CreateWindow API is returning null HWND. Calling AtlAxWinInit() before CreateWindow() API as shown below:

CreateControl()
{
    AtlAxWinInit();
    HWND hwndChild =   CreateWindow(_T("AtlAxWin"),
    _T("test"),
    WS_CHILD|WS_VISIBLE,
    0,0,0,0,
    hwnd,NULL,
    ::GetModuleHandle(NULL),
    NULL);
}

GetLastError() 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..

1

There are 1 best solutions below

0
On

The ATL window class name was changed in the different versions of Visual Studio. It is "AtlAxWin140" for VS 2019.

The atldef.h file defines the current version of the windows class name in the following macro: ATLAXWIN_CLASS

You should use the ATLAXWIN_CLASS macro instead of _T("AtlAxWin").