Article View: borland.public.cppbuilder.nativeapi
Article #12807Re: Hooking to Windows ToolTips
From: Marc
Date: Tue, 18 Nov 2003 14:58
Date: Tue, 18 Nov 2003 14:58
105 lines
4672 bytes
4672 bytes
Hi
>Can I somehow retrieve the tooltip handle, to modify its
>Text.
Incase anyone is interested here is the answer to the previous
post.
NMHDR *pNMHDR;
pNMHDR = (NMHDR*)pPreMsg->lParam;
UINT nID = static_cast<UINT>( pNMHDR->idFrom );
HWND hWndTT = GetDlgItem(pPreMsg->hwnd, nID);
Now how do I change the text, I seem to only get garbage.
TOOLTIPTEXTW* pTTTW = reinterpret_cast<TOOLTIPTEXTW*>( pPreMsg->lParam );
char* stTestX = new char;
stTestX = "1234567890";
pTTTW->lpszText = (LPWSTR)stTestX;
The tooltip text gets modified but it shows garbage.
Marc
"Marc" <remove_Bukwheat@axess.com> wrote:
>
>Hi
>
>Thanks Remy, I am getting closer to the goal.
>
>I am running windows XP and I am capable of detecting a
>tooltip is about to be shown, from the bottom task bar.
>Using the SetWindowsHookEx() and WM_NOTIFY i get the
>TTN_SHOW message. I don't get the TTN_GETDISPINFO or
>TTN_NEEDTEXT. The message that is recieved, comes from the
>TaskBar so when I ask for the handle of the window, I get
>the TaskBar handle not the tooltip handle.
>
>Can I somehow retrieve the tooltip handle, to modify its
>Text.
>
>Thanks
>Marc
>
>Ps Here is what I tried to modify the text:
>The pTTTW pointer text part is invalid
>void OnNotify(IN CWPSTRUCT *pPreMsg)
>{
> OFNOTIFY *pOFN = (OFNOTIFY*)pPreMsg->lParam;
>
> NMHDR *pNMHDR;
> pNMHDR = (NMHDR*)pPreMsg->lParam;
>
> if (pNMHDR->code == TTN_SHOW)
> {
>// MessageBox(0,"TTN_SHOW","TTN_SHOW", MB_OK);
> TOOLTIPTEXT* pTTTW = reinterpret_cast<TOOLTIPTEXT*>( pPreMsg->lParam );
> UINT nID = static_cast<UINT>( pNMHDR->idFrom );
>
> RECT rcWnd;
> GetWindowRect(pPreMsg->hwnd, &rcWnd);
>
> char Buffer[512];
> wsprintf(Buffer,"Top:%d Left:%d Bottom:%d Right:%d \r\n", rcWnd.top, rcWnd.left, rcWnd.bottom, rcWnd.right);
> OutputDebugString(Buffer);
> }
>
>
>"Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> wrote:
>>
>>"Marc" <remove_Bukwheat@axess.com> wrote in message
>>news:3fb8e5d5$1@newsgroups.borland.com...
>>
>>> The class subclassing also doesn't seem to work.
>>
>>You cannot subclass external windows. If you want to intercept messages
>>from other applications, then you must use a message hook dll via
>>SetWindowsHookEx().
>>
>>> What I am trying to do, is trap the fact that a tooltip is
>>> about to be displayed, and modify the text of it, and maybe
>>> even its location if needed. I already have achieved this
>>> with system menus, but can't do it with tooltips. Where does
>>> widows do its messaging for tooltips?
>>
>>Tooltips are handled on a per-application, per-window basis. Each
>>individual application creates and displays its own tooltip windows when
>>appropriate, like any other window.
>>
>>However, even that is not standardized. VCL apps, for example, handle
>>tooltips very differently than, say, VB or VC++. The VCL uses its own
>>standalone THintWindow class, which has nothing to do with the native
>>tooltip features provided by the Win32 API. In fact, the VCL has no concept
>>of the API tooltips at all. On the other hand, those applications that do
>>use true API tooltips will most likely receive a WM_NOTIFY message
>>containing either a TTN_GETDISPINFO or TTN_NEEDTEXT notification just prior
>>to displaying the tooltip, so you can try looking for those notifications in
>>your message hook.
>>
>>
>>Gambit
>>
>>
>
Technical Details
Message-ID:
<3fba41b8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fb3ef78$1@newsgroups.borland.com> <3fb3f737@newsgroups.borland.com> <3fb4ec69$1@newsgroups.borland.com> <3fb5015f$1@newsgroups.borland.com> <3fb514e5$1@newsgroups.borland.com> <3fb522c0$1@newsgroups.borland.com> <3fb8e5d5$1@newsgroups.borland.com> <3fb90c0a@newsgroups.borland.com> <3fba3491$2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,77f5c963a5b23dbd X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-11-18 08:10:30 PST From: "Marc" <Remove_Bukwheat@axess.com> Sender: "Marc" <Remove_Bukwheat@axess.com> Reply-To: "Marc" <Remove_Bukwheat@axess.com> Subject: Re: Hooking to Windows ToolTips Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 138.11.254.204 X-Forwarded-For: unknown References: <3fb3ef78$1@newsgroups.borland.com> <3fb3f737@newsgroups.borland.com> <3fb4ec69$1@newsgroups.borland.com> <3fb5015f$1@newsgroups.borland.com> <3fb514e5$1@newsgroups.borland.com> <3fb522c0$1@newsgroups.borland.com> <3fb8e5d5$1@newsgroups.borland.com> <3fb90c0a@newsgroups.borland.com> <3fba3491$2@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <3fba41b8$1@newsgroups.borland.com> Date: 18 Nov 2003 07:58:48 -0700 X-Trace: newsgroups.borland.com 1069171128 207.105.83.66 (18 Nov 2003 07:58:48 -0700) Lines: 106 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail