标识符"PLVGROUP"未定义 afxcmn.h

identifier "PLVGROUP" is undefined afxcmn.h

本文关键字:afxcmn PLVGROUP 标识符 未定义      更新时间:2023-10-16

我有一个Visual Studio 2015项目,它使用afxcmn标头,并且有很多"未定义"错误。

我在文档中读到这些数据类型包含在commctrl.h中,它已经作为外部依赖项包含在Visual Studio项目中。

// Adds a group to the control.
AFX_ANSI_DEPRECATED int InsertGroup(_In_ int index, _In_ PLVGROUP pgrp);
// Sets information about the specified group (by ID) in the control.
AFX_ANSI_DEPRECATED int SetGroupInfo(_In_ int iGroupId, _In_ PLVGROUP pGroup);
// Retrieves information for the specified group in the control.
AFX_ANSI_DEPRECATED int GetGroupInfo(_In_ int iGroupId, _Out_ PLVGROUP pgrp) const;

这是afxcmn.h的一些代码示例,它给出了这些错误。

我不知道我是否必须在项目中配置其他内容,以包括commctrl标头

是的,PLVGROUP是在commctrl.h中定义的,但它取决于WINVER

#if (NTDDI_VERSION >= NTDDI_WINXP)

这意味着WINVER>=501,请参阅:

error Direktive:MFC不支持小于0x0501的WINVER。请在项目属性或预编译头中更改WINVER的定义。

所以我不得不更改我的stdafx.h //#define WINVER 0x0500 #define WINVER NTDDI_WINXP //0x05010000

它们是Visual Studio 2015生成的IntelliSense错误。

我的环境是Windows 10 1903/VS2017

我不知道确切的原因,但这为我解决了问题:

仅供参考,这是我项目中产生问题错误的原始stdafx.h:

#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN        // Exclude rarely-used stuff from Windows headers
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER              // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0400       // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif
#ifndef _WIN32_WINNT        // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif                      
#ifndef _WIN32_WINDOWS          // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410   // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE           // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0400    // Change this to the appropriate value to target IE 5.0 or later.
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS  // some CString constructors will be explicit
......

在"#pragmaonce"下面加上这两行之后,问题就解决了:

#define WINVER 0x0603
#define _WIN32_WINNT 0x0603

仅添加第一行仍然会产生这些错误。