简体   繁体   English

CreateWindow 找不到 window class

[英]CreateWindow could not find window class

Am using CreateWindow() API which was working correctly on VS2015 before upgrading to VS2019.我正在使用CreateWindow() API,它在升级到 VS2019 之前在 VS2015 上正常工作。 After upgrading to VS2015 CreateWindow API is returning null HWND.升级到 VS2015 CreateWindow API 后返回 null HWND。 Calling AtlAxWinInit() before CreateWindow() API as shown below:CreateWindow() API 之前调用AtlAxWinInit()如下所示:

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 : GetLastError()返回 1407 错误代码,即ERROR_CANNOT_FIND_WND_CLASS

Cannot find window class.找不到 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. ATL window class 名称在 Visual Studio 的不同版本中已更改。 It is " AtlAxWin140 " for VS 2019.它是 VS 2019 的“ AtlAxWin140 ”。

The atldef.h file defines the current version of the windows class name in the following macro: ATLAXWIN_CLASS atldef.h文件在以下宏中定义了 windows class 名称的当前版本: ATLAXWIN_CLASS

You should use the ATLAXWIN_CLASS macro instead of _T("AtlAxWin").您应该使用ATLAXWIN_CLASS宏而不是 _T("AtlAxWin")。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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