Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages
Started by Mike Collins
Sat, 26 May 2007 00:09
Balloon Tips auto popups
Author: Mike Collins
Date: Sat, 26 May 2007 00:09
Date: Sat, 26 May 2007 00:09
60 lines
3258 bytes
3258 bytes
Hi all, feel a bit embarrassed asking this, since I just did an article for
the bib journal, but can anyone help me with my Balloon Tip issues. I have
a Balloon Tip created for a panel, using the code below. I only specify the
NIF_INFO flag and this seems to be sufficient to get the balloon tip to show
when i mouse over the panel, and the be hidden when the mouse moves away.
However, i now need to force the Balloon To show, in order to bring the
users attention to the panel.. I need to force this from code, not from the
user mouse-overing. I though i could do this simply enough by calling:
SendMessage(hWnd, (UINT)TTM_ACTIVATE,(WPARAM)TRUE, 0);
but it doesn't seem to do anything. Can anyone point me in the right
direction here - sure i'm missing something with the flags but MSDN is a
nightmare.
My wrapper looks like this:
void Form::AssignBalloonTip(HWND &p_hTTips, TOOLINFO &p_ti, TWinControl
*p_WinControl,
const AnsiString &p_szTitle, const
AnsiString &p_szBody,
UINT p_uIcon, UINT p_uFlags, TColor
clBackCL, TColor clTextCL)
{
p_hTTips = CreateWindow("tooltips_class32", NULL,
WS_POPUP | TTS_NOPREFIX | TTS_BALLOON |
TTS_ALWAYSTIP,
0, 0, 0, 0, NULL, NULL, HInstance, NULL);
if (p_hTTips)
{
ZeroMemory(&p_ti, sizeof(p_ti));
p_ti.cbSize = sizeof(p_ti);
p_ti.uFlags = p_uFlags;
p_ti.hwnd = p_WinControl->Handle;//hSrcWnd;
p_ti.uId = 0;
p_ti.hinst = NULL;
p_ti.lpszText = p_szBody.c_str();
SetWindowPos(p_hTTips, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE);
::GetClientRect(p_WinControl->Handle, &p_ti.rect);
SendMessage(p_hTTips, TTM_SETTIPBKCOLOR, clBackCL, 0);
SendMessage(p_hTTips, TTM_SETTIPTEXTCOLOR, clTextCL, 0);
SendMessage(p_hTTips, TTM_SETTITLE, p_uIcon, (int)p_szTitle.c_str());
SendMessage(p_hTTips, TTM_ADDTOOL, 0, (LPARAM)&p_ti);
}
}
and i'm calling it like this:
AssignBalloonTip(hPanWnd, tiPanTip, Panel1,
"Some title",
"body of text",
TTI_ERROR, NIF_INFO,
(TColor)clCream, (TColor)clBlack);
Many thanks in advance,
Mike
Re: Balloon Tips auto popups
Author: Bob Gonder
Date: Sat, 26 May 2007 00:26
Date: Sat, 26 May 2007 00:26
63 lines
3021 bytes
3021 bytes
Mike Collins wrote:
>However, i now need to force the Balloon To show, in order to bring the
>users attention to the panel.. I need to force this from code, not from the
>user mouse-overing. I though i could do this simply enough by calling:
>
> SendMessage(hWnd, (UINT)TTM_ACTIVATE,(WPARAM)TRUE, 0);
hWnd needs to be the HWND of the control (p_hTTips or
Panel1->Handle?).
Your code didn't show this line though.
>but it doesn't seem to do anything. Can anyone point me in the right
>direction here - sure i'm missing something with the flags but MSDN is a
>nightmare.
>if (p_hTTips)
> {
> ZeroMemory(&p_ti, sizeof(p_ti));
> p_ti.cbSize = sizeof(p_ti);
isn't p_ti a pointer (reference) ?
what is the size of a reference?
> p_ti.uFlags = p_uFlags; //NIF_INFO,
NIF_INFO is not listed as a uFlag value.
http://msdn2.microsoft.com/en-us/library/ms650460.aspx
Try TTF_SUBCLASS
> p_ti.hwnd = p_WinControl->Handle;//hSrcWnd;
> p_ti.uId = 0;
> p_ti.hinst = NULL;
I think that needs to be real (maybe only if Text is a resource)
> p_ti.lpszText = p_szBody.c_str();
p_szBody is a temporary which is deleted as soon as you return from
this routine.
>void Form::AssignBalloonTip(HWND &p_hTTips,
> TOOLINFO &p_ti, TWinControl *p_WinControl,
> const AnsiString &p_szTitle, const AnsiString&p_szBody,
> UINT p_uIcon, UINT p_uFlags,
> TColor clBackCL, TColor clTextCL)
> AssignBalloonTip(hPanWnd,
> tiPanTip, Panel1,
> "Some title", "body of text",
> TTI_ERROR, NIF_INFO,
> (TColor)clCream, (TColor)clBlack);
Ok, now the Google links that show how do it another way:
THintWindow:
http://groups.google.com/group/alt.comp.lang.borland-delphi/browse_thread/thread/cedde909c84f8255/904d39234d8706b8
http://tinyurl.com/2nkhbp
(Expand the messages at the bottom)
THintWindow:
http://groups.google.com/group/borland.public.delphi.language.delphi.general/browse_thread/thread/e53c4da619491e3b/4bd61436f18c39f7
http://tinyurl.com/2au2vn
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads