Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Balloon Tooltip
Author:Tornado
Category:Win32API
File Size:~ 1.55 KB
Uploaded at:20-Dec-02 04:26:17 am
Description:
  This is the way to create a ballon tooltip in your applications.
  
// This shows how to attach a tooltip to a control,
// and make it a balloon shaped.
// Thanks go to Saar(tornado@goblineye.com) for this code!!

// Create the tooltip
// The tooltip is created as top-most so the parent will never hide it
// Also, created as a cool baloon tooltip

HWND hwndTool = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hDlg, NULL, g_hInstance, NULL);

TOOLINFO toolInfo;
toolInfo.cbSize = sizeof(toolInfo);
// The tooltip subclasses the tool it uses so it can intercept messages like WM_MOUSEMOVE etc,
// we also mention the uId will be the handle to the tool
toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
// Handle to the window that contains the tool
toolInfo.hwnd = hDlg;
// Handle to the tool (in this case: a listview control)
toolInfo.uId = (unsigned int)GetDlgItem(hDlg, IDC_MAINLISTCTRL);
// The text that always appears
toolInfo.lpszText = "Some useful info";

// Add the tool to the control
SendMessage(hwndTool, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
// Set a nice title to the baloon
SendMessage(hwndTool, TTM_SETTITLE, 1, (LPARAM)"Title of tooltip");
// Activate the tooltip
SendMessage(hwndTool, TTM_ACTIVATE, true, 0);
// and viola, finished.
// Remember to destroy the window later when you're done
DestroyWindow(hwndTool);

BTW - Don't forget to init common controls ( for the list view )!
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC  = ICC_TREEVIEW_CLASSES;
InitCommonControlsEx(&icex); 
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[106775]
2D Rotated Rectangles Collision Detection[79918]
Keyboard Hook[69063]
UDP[53058]
HTTP Proxy[36303]

::Top 5 Samples::
2D ColDet Rotated Rectangles[10638]
PS2 Mouse Driver[6122]
Wave Format Player[5005]
Reading FAT12[4893]
CodeGuru[4579]


All rights reserved to RageStorm © 2009