gpt4 book ai didi

winapi - 通过 TTM_TRACKACTIVATE 显示工具提示不起作用

转载 作者:行者123 更新时间:2023-12-02 14:04:29 26 4
gpt4 key购买 nike

在后台进程中,我想在托盘区域中像气球一样显示短信。但是,我不想为此添加托盘图标。因此,我创建了一个工具提示图标并希望将其放置在托盘附近。但是,发送 TTM_UPDATETIPTEXTTTM_TRACKPOSITIONTTM_TRACKACTIVATE 返回 0。虽然我不确定是否应该是这种情况,但以下代码确实如此显示工具提示窗口,我不知道为什么:

这是代码:

// "hwnd" is the HWND to the hidden background window of my background process
HWND hTrayWnd = FindWindow(_T("Shell_TrayWnd"), NULL);
GetWindowRect(hTrayWnd, &trayPos);
HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_ALWAYSTIP | TTS_BALLOON,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, NULL, NULL, NULL);
LRESULT ret;
TOOLINFO toolInfo = { 0 };
ZeroMemory(&toolInfo, sizeof(toolInfo));
toolInfo.cbSize = sizeof(toolInfo);
toolInfo.hinst = GetModuleHandle(NULL);
toolInfo.lpszText = _T("Test Test");
toolInfo.hwnd = hWnd;
ret = SendMessage(hwndTip, TTM_SETTITLE, TTI_INFO , (LPARAM)_T("Test Title"));

此调用返回零:

ret = SendMessage(hwndTip, TTM_UPDATETIPTEXT, 0 , (LPARAM)&toolInfo); // needs hinst, lpszText, hwnd, cbSize

此调用也返回零:

ret = SendMessage(hwndTip, TTM_TRACKPOSITION, 0, MAKELPARAM(trayPos.left, trayPos.top));
ZeroMemory(&toolInfo, sizeof(toolInfo));
toolInfo.cbSize = sizeof(toolInfo);
toolInfo.hwnd = hWnd;
toolInfo.uId = 1;

还有这个:

ret = SendMessage(hwndTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolInfo); // needs hwnd, uId, cbSize

并且工具提示窗口永远不会显示。

我还尝试使用 TTM_ADDTOOL (如评论中的建议)广告我的 SendMessage 调用的不同顺序,但这也返回零并且不显示工具提示:

LRESULT ret;
TOOLINFO toolInfo = { 0 };
ZeroMemory(&toolInfo, sizeof(toolInfo));
toolInfo.cbSize = sizeof(toolInfo);
toolInfo.lpszText = _T("Test Test");
toolInfo.hwnd = hWnd;
toolInfo.uId = 1;
toolInfo.rect.bottom = trayPos.bottom;
toolInfo.rect.left = trayPos.left;
toolInfo.rect.right = trayPos.right;
toolInfo.rect.top = trayPos.top;

//ret = SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
ret = SendMessage(hwndTip, TTM_SETTITLE, TTI_INFO , (LPARAM)_T("Test Title"));
//ret = SendMessage(hwndTip, TTM_UPDATETIPTEXT, 0 , (LPARAM)&toolInfo); // needs hinst, lpszText, hwnd, uId, cbSize
//ret = SendMessage(hwndTip, TTM_TRACKPOSITION, 0, MAKELPARAM(trayPos.left, trayPos.top));
//ret = SendMessage(hwndTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&toolInfo); // needs hwnd, uId, cbSize
ret = SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);

最佳答案

TTM_TRACKACTIVATE 激活“跟踪工具提示”,该提示是通过在 TOOLINFO::uFlags 中设置 TTF_TRACK 创建的。

关于winapi - 通过 TTM_TRACKACTIVATE 显示工具提示不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30253205/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com