关于tooltips 用win32写了一个图片窗口程序,上面的按钮都是图片,通过鼠标区域检测来实现功能。想给这些按钮加上tooltips,但是他们不像dialog上面的按钮那样,有ID,可以使用tooltips。请问有什么好的方法实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以指定ToolTip只在圖片窗口的某一個區域内出現void CreateMyTooltip (HWND hwnd){ // struct specifying control classes to register INITCOMMONCONTROLSEX iccex; HWND hwndTT; // handle to the ToolTip control // struct specifying info about tool in ToolTip control TOOLINFO ti; unsigned int uid = 0; // for ti initialization char strTT[30] = "This is your ToolTip string."; LPTSTR lptstr = strTT; RECT rect; // for client area coordinates /* INITIALIZE COMMON CONTROLS */ iccex.dwICC = ICC_WIN95_CLASSES; iccex.dwSize = sizeof(INITCOMMONCONTROLSEX); InitCommonControlsEx(&iccex); /* CREATE A TOOLTIP WINDOW */ hwndTT = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, NULL, ghThisInstance, NULL ); SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); /* GET COORDINATES OF THE MAIN CLIENT AREA */ GetClientRect (hwnd, &rect); /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */ ti.cbSize = sizeof(TOOLINFO); ti.uFlags = TTF_SUBCLASS; ti.hwnd = hwnd; ti.hinst = ghThisInstance; ti.uId = uid; ti.lpszText = lptstr; // ToolTip control will cover the whole window // 改這裡就行 坐標相對于指定窗口客戶區的左上角 ti.rect.left = rect.left; ti.rect.top = rect.top; ti.rect.right = rect.right; ti.rect.bottom = rect.bottom; /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */ SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); } Debug下的运行问题 不明白 为什么gdiBitmap始终是0000 ??? 关于网络编程中的多线程问题(急) Picture Control如何用?? 串口通信的一个问题 安装问题(急!) unicode debug 是一种什么编译方式 有朋友遇到if(){XX}else{YY}里面XX YY都执行的么 请问大家一些:大家在做C++开发时,一般怎么检测内存泄露?? clistctrl icon风格时,文字换行 重载CStatic类出现的问题 MFC 弹出的对话框LIST初始化问题
{
// struct specifying control classes to register
INITCOMMONCONTROLSEX iccex;
HWND hwndTT; // handle to the ToolTip control
// struct specifying info about tool in ToolTip control
TOOLINFO ti;
unsigned int uid = 0; // for ti initialization
char strTT[30] = "This is your ToolTip string.";
LPTSTR lptstr = strTT;
RECT rect; // for client area coordinates /* INITIALIZE COMMON CONTROLS */
iccex.dwICC = ICC_WIN95_CLASSES;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx(&iccex); /* CREATE A TOOLTIP WINDOW */
hwndTT = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hwnd,
NULL,
ghThisInstance,
NULL
); SetWindowPos(hwndTT,
HWND_TOPMOST,
0,
0,
0,
0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); /* GET COORDINATES OF THE MAIN CLIENT AREA */
GetClientRect (hwnd, &rect); /* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = hwnd;
ti.hinst = ghThisInstance;
ti.uId = uid;
ti.lpszText = lptstr;
// ToolTip control will cover the whole window
// 改這裡就行 坐標相對于指定窗口客戶區的左上角
ti.rect.left = rect.left;
ti.rect.top = rect.top;
ti.rect.right = rect.right;
ti.rect.bottom = rect.bottom; /* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti); }