简体   繁体   中英

CreateWindow could not find window class

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..

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").

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM