WTL 9.0的变化 - atlapp.h
忽然发现WTL更新到9.0.4140了,便对比了一下 8.1.12085。
先看看atlapp.h中有什么大的变动。
第61行:
#if defined(_SYSINFOAPI_H_) && defined(NOT_BUILD_WINDOWS_DEPRECATE) && (_WIN32_WINNT >= 0x0501) #include <VersionHelpers.h> #endif
XP以及上的系统可以用 VersionHelpers.h中一些更方便的工具函数来判断windows版本了,例如:IsWindowsXPOrGreater()、IsWindowsXPSP3OrGreater()、IsWindows8OrGreater(),同时VC2013编译时也会警告GetVersionEx等API已经过时,所以WTL 9引入了这些新API,并改写之前WTL版本,如:
inline bool IsVista() { #ifdef _versionhelpers_H_INCLUDED_ return ::IsWindowsVistaOrGreater(); #else // !_versionhelpers_H_INCLUDED_ OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; BOOL bRet = ::GetVersionEx(&ovi); return ((bRet != FALSE) && (ovi.dwMajorVersion >= 6)); #endif // _versionhelpers_H_INCLUDED_ }
inline bool IsWin7() { #ifdef _versionhelpers_H_INCLUDED_ return ::IsWindows7OrGreater(); #else // !_versionhelpers_H_INCLUDED_ OSVERSIONINFO ovi = { sizeof(OSVERSIONINFO) }; BOOL bRet = ::GetVersionEx(&ovi); return ((bRet != FALSE) && (ovi.dwMajorVersion == 6) && (ovi.dwMinorVersion >= 1)); #endif // _versionhelpers_H_INCLUDED_ }
第1165行:
// GenericWndClass - generic window class usable for subclassing // Use in dialog templates to specify a placeholder to be subclassed // Specify as a custom control with class name WTL_GenericWindow // Call Rregister() before creating dialog (for example, in WinMain) namespace GenericWndClass { inline LPCTSTR GetName() { return _T("WTL_GenericWindow"); } inline ATOM Register() { WNDCLASSEX wc = { sizeof(WNDCLASSEX) }; wc.lpfnWndProc = ::DefWindowProc; wc.hInstance = ModuleHelper::GetModuleInstance(); wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszClassName = GetName(); ATOM atom = ::RegisterClassEx(&wc); ATLASSERT(atom != 0); return atom; } inline BOOL Unregister() // only needed for DLLs or tmp use { return ::UnregisterClass(GetName(), ModuleHelper::GetModuleInstance()); } }; // namespace GenericWndClass
这是三个新增的函数,看注释知道,是用于subclass之类的,还没看到具体该怎样用。注释里WTL作者居然写错字了,嘿嘿。