Tooltip 不能显示
Tooltip 不能显示
SendMessage ( m_hTooltip, TTM_DELTOOL, 0, (LPARAM)&ti );
返回0, GetLastError()=1400 ERROR_INVALID_WINDOW_HANDLE
Root cause:
typedef struct tagTOOLINFOW {
UINT cbSize;
UINT uFlags;
HWND hwnd;
UINT_PTR uId;
RECT rect;
HINSTANCE hinst;
LPWSTR lpszText;
#if (_WIN32_IE >= 0x0300)
LPARAM lParam;
#endif
#if (_WIN32_WINNT >= 0x0501)
void *lpReserved;
#endif
} TTTOOLINFOW, NEAR *PTOOLINFOW, *LPTTTOOLINFOW;
编译的时候_WIN32_WINNT=0x0501,但是调用的ComCtrl32.dll是老版本的,导致传进去的TOOLINFO不匹配。
Solution:
给工程添加manifest:
命名为<filename>.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="filename"
processorArchitecture="x86"
version="1.0.0.1"
type="win32"/>
<description>description…</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
参考文章
http://blog.csdn.net/gulongwan/archive/2009/03/01/3947190.aspx