Windows 8.1下InitCommonControlsEx()使用ICC_LINK_CLASS时失败
InitCommonControlsEx() fails with ICC_LINK_CLASS in Windows 8.1
我想在我的窗口放一个简单的超链接。
INITCOMMONCONTROLSEX iccx;
iccx.dwSize = sizeof(INITCOMMONCONTROLSEX);
iccx.dwICC = ICC_LINK_CLASS; // CommCtrl.h: #define ICC_LINK_CLASS 0x00008000
bool bResult = InitCommonControlsEx(&iccx); // bResult is false.
DWORD dwError = GetLastError(); // dwError is 0.
hWnd = CreateWindowExW( /*_In_ DWORD*/ 0,
/*_In_opt_ LPCTSTR*/ WC_LINK, // CommCtrl.h: #define WC_LINK L"SysLink"
/*_In_opt_ LPCTSTR*/ L"Hello World",
/*_In_ DWORD*/ WS_VISIBLE | WS_CHILD | WS_TABSTOP,
/*_In_ int*/ 50,
/*_In_ int*/ 200,
/*_In_ int*/ 100,
/*_In_ int*/ 20,
/*_In_opt_ HWND*/ hWndParent,
/*_In_opt_ HMENU*/ NULL,
/*_In_opt_ HINSTANCE*/ hInstance,
/*_In_opt_ LPVOID*/ NULL);
DWORD dwError = GetLastError(); // hWnd is NULL and dwError is 1407.
错误码1407在这里解释如下。
ERROR_CANNOT_FIND_WND_CLASS
1407 (0x57F)
Cannot find window class.
我用的是Windows 8.1 Pro x64,我从来没有在任何其他版本的Windows上尝试过这段代码。
这里有什么问题?
正如你所发现的,添加
#pragma comment(linker,"/manifestdependency:"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'"")
是解决问题的一种方法。
SysLink控件仅在通用控件版本6中添加。出于向后兼容性的原因,默认情况下不启用Common Controls 6。你必须通过创建一个清单来选择加入它。
清单可以作为单独的文件(命名为program.exe.manifest
)存在,也可以作为具有特定资源ID的资源存在。#pragma
行告诉Microsoft的链接器为您生成第二个。你也可以自己制作任何一种形式。这是如何。
相关文章:
- LINK 尝试使用 OpenSSL evp aes 256 c++ 时出错
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 使用模板进行堆栈实现; "name followed by :: must be a class or namespace"
- "Undefined class"作为is_base_of的论据
- 如何将class.cpp和class.hpp编译为一个.o文件
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- '{'标记之前的预期类名,然后在预声明时无效使用不完整的类型'class class_name'
- 如何使用"derived input class"创建派生类?
- 错误:"Left of getValue must have class/struct/union"
- ' class a : b ' 和 ' class a : public b ' 之间的继承类不同
- Pybind11 Class Definition
- 在C++中使用没有合作伙伴Class/Cpp文件的头文件是否实用
- C2011 'CMemDC':Visual Studio 2019中的'class'类型重新定义
- TypeError: [c++ addon class] 不是构造函数
- C++ class template
- 当初始值设定项是基类名时'initializer does not name a non-static data member or base class'错误
- Clearing Class Foo with new(pFoo) Foo()
- C++ class vs a library
- 继承类时"invalid use of incomplete type ‘class tree_node_t’"