|
-
December 30th, 2010, 04:07 PM
#1
Tooltips without parent (on desktop)
I'm trying to display a balloon tooltip on the screen without specifying a parent window for it.
For this application purpose, my tooltip data and handle is "encapsulated" in my own handle definition (HBUBBLE):
Code:
struct __HBUBBLE {
HWND hwnd;
TOOLINFO ti;
};
typedef __HBUBBLE* HBUBBLE;
My creation code where I'm trying to create it and show is as follows.
Code:
DWORD BubbleWindow_Create(HBUBBLE* pHandle)
{
DWORD rv = 0;
HWND hwnd = NULL;
RECT rcDesktop;
GetClientRect(GetDesktopWindow(), &rcDesktop);
hwnd = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, TTS_ALWAYSTIP | TTS_BALLOON | WS_POPUP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, GetModuleHandle(0), NULL);
rv = (DWORD) hwnd;
if (hwnd)
{
*pHandle = new __HBUBBLE;
memset ( & ((*pHandle)->ti), 0, sizeof(TOOLINFO));
(*pHandle)->ti.cbSize = sizeof(TOOLINFO);
(*pHandle)->ti.hinst = 0;
(*pHandle)->ti.uFlags = TTF_TRACK | TTF_ABSOLUTE | TTF_IDISHWND;
(*pHandle)->ti.hwnd = GetDesktopWindow();
(*pHandle)->ti.uId = (UINT_PTR) GetDesktopWindow();
(*pHandle)->ti.lpszText = L"XXXXX";
CopyRect(& ((*pHandle)->ti.rect), &rcDesktop);
SendMessage(hwnd, TTM_ADDTOOL, 0, (LPARAM) &((*pHandle)->ti));
SendMessage(hwnd, TTM_SETTITLE, TTI_INFO, (LPARAM) L"xxxxxx TITLE xxxxx");
SendMessage(hwnd, TTM_SETDELAYTIME, TTDT_AUTOMATIC, -1);
SendMessage(hwnd, TTM_SETMAXTIPWIDTH, 0, 500);
SendMessage(hwnd, TTM_TRACKACTIVATE, TRUE, (LPARAM) &((*pHandle)->ti));
SendMessage(hwnd, TTM_TRACKPOSITION, 0, 0);
//SetWindowPos (hwnd, HWND_TOPMOST, 0, 0, 200, 200, SWP_NOSIZE);
(*pHandle)->hwnd = hwnd;
}
else
dprintf(L"BubbleWindow_Create:WindowCreation failed\n");
return rv;
}
It's possible to do this? Or I must create a parent window for it?
Thank you very much!
pd: (offtopic!) Has "code" tag on the forum C/C++ highlighting capabilities?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|