Add tool tip to menu
-
Does anyone know how possible this one was made (this is link to picture): https://i.ibb.co/nCrT1Ty/howtodothis.png[^] Maybe someone has samples of similar project or link to such project. Thanks.
-
Does anyone know how possible this one was made (this is link to picture): https://i.ibb.co/nCrT1Ty/howtodothis.png[^] Maybe someone has samples of similar project or link to such project. Thanks.
Try: CListCtrl and Displaying a Tooltip[^] MFC List Control with Tooltip and Menu Ability[^]
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Does anyone know how possible this one was made (this is link to picture): https://i.ibb.co/nCrT1Ty/howtodothis.png[^] Maybe someone has samples of similar project or link to such project. Thanks.
It's easy to add to any window using just the Windows API .. So you have a window Handle (hWnd) and you have a char* tooltip you wish to display First you must make sure commoncontrols is kicked
#include
#pragma comment(lib, "comctl32.lib") // Shortcut to add library rather than manual addINITCOMMONCONTROLSEX icex = {
.dwSize = sizeof(INITCOMMONCONTROLSEX),
.dwICC = ICC_STANDARD_CLASSES
};
InitCommonControlsEx(&icex);Now create the tooltip window .. we will default to same area as window itself you can size it if you want
HWND TTWnd = CreateWindowEx (WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP | TTS_BALLOON,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, 0, 0, NULL); // Create tooltip windowif (TTWnd) // Tooltip window successfully created
{
TOOLINFO ti = { 0 };
SetWindowPos(TTWnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); // Set window position
ti.cbSize = sizeof(TOOLINFO); // Size of structure
ti.uFlags = TTF_SUBCLASS; // Class
ti.hwnd = hWnd; // Parent window is YOUR HANDLE OF YOUR WINDOW
ti.hinst = 0; // This instance
ti.uId = 0; // No uid
ti.lpszText = tooltip; // YOUR TOOLTIP text pointer
GetClientRect(hWnd, &ti.rect); // Tooltip to cover whole window
SendMessage(TTWnd, TTM_ADDTOOL, 0, (LPARAM)&ti); // Send message adding tooltip to window
}Try it on any window you like :-)
In vino veritas
-
Does anyone know how possible this one was made (this is link to picture): https://i.ibb.co/nCrT1Ty/howtodothis.png[^] Maybe someone has samples of similar project or link to such project. Thanks.
-
First of all I cannot use MFC. I have made WM_MENUSELECT handling in the dialog: case WM_MENUSELECT: return OnMyMenuSelect(LOWORD(wpar), HIWORD(wpar), (HMENU)lpar); However function IsMenu((HMENU)lpar) returns FALSE. Does anybody has idea why ?