f



Updating/changing a tooltip_class32 text ?

Hello all,

I've put an icon in the SysTray and given it a tooltip text.  Hovering over
the icon displays the tooltip nicely.

I can also update the tooltip text, but only when the mouse moves off and
than on the icon again the new tooltip is shown.

Question : how do I change the shown tooltip text dynamically ?


I've been able to get the handle to the tooltip itself, but a WM_SETTEXT
seems to be ignored, and sending a TTM_UPDATETIPTEXT message crashes the
target app (most likely because the provided record is in memory not
readable by the target process).

WM_COPYDATA seems to be unusable both because the target app has no idea
what to do with it as well as the TOOLINFO structure containing a pointer to
some text (the stuff I want to have displayed :-) ), which is not permitted
when using WM_COPYDATA.

I've been thinking about using shared memory, but as that works with handles
and the target app expects a simple memory reference I don't think thats
going to work either ...

Regards,
Rudy Wieser



0
R
12/8/2016 1:01:01 AM
comp.os.programmer.win32 14523 articles. 0 followers. Post Follow

4 Replies
224 Views

Similar Articles

[PageSpeed] 41

JJ,

> if you use TTM_UPDATETIPTEXT, the pointer to the
> TOOLINFO structure including all of the pointers in the structure
> fields point to address space in your application process, not the
> shell process'. i.e. the shell process will try to read data which isn't
> there.

Yep, thats what I ment with "(most likely because the provided record is in
memory not readable by the target process)."

> Also, WM_GETTEXT/WM_SETTEXT don't work on tooltip controls.

The first does, the second, as mentioned, does not (info: When a tooltip
disappears its contents seem to get cleared -- which might look as if
WM_GETTEXT fails.  But as long as the tooltip is visible you can read
whatever its displaying).

> I haven't tried it yet, but try InvalidateRect() the tooltip window
> after changing the tray's tooltip text via Shell_NotifyIcon()

Good one, might work.

> The other alternative method is to use window hook which is hacky.
> It'll also solve the WM_COPYDATA and shared memory issues.

Hmmm ....

> But I recall you're not a fan of hacky ways.

Quite true.   I rather have a way which I can use without having to worry
about if it will or won't keel over in the presence of other software (or
hacks :-) )

Regards,
Rudy Wieser


-- Origional message:
JJ <jj4public@vfemail.net> schreef in berichtnieuws
lvtwia0gb1ae$.jb7v3lnlzi7q.dlg@40tude.net...
> On Thu, 8 Dec 2016 09:28:40 +0100, R.Wieser wrote:
> > Hello all,
> >
> > I've put an icon in the SysTray and given it a tooltip text.  Hovering
over
> > the icon displays the tooltip nicely.
> >
> > I can also update the tooltip text, but only when the mouse moves off
and
> > than on the icon again the new tooltip is shown.
> >
> > Question : how do I change the shown tooltip text dynamically ?
> >
> > I've been able to get the handle to the tooltip itself, but a WM_SETTEXT
> > seems to be ignored, and sending a TTM_UPDATETIPTEXT message crashes the
> > target app (most likely because the provided record is in memory not
> > readable by the target process).
> >
> > WM_COPYDATA seems to be unusable both because the target app has no idea
> > what to do with it as well as the TOOLINFO structure containing a
pointer to
> > some text (the stuff I want to have displayed :-) ), which is not
permitted
> > when using WM_COPYDATA.
> >
> > I've been thinking about using shared memory, but as that works with
handles
> > and the target app expects a simple memory reference I don't think thats
> > going to work either ...
> >
> > Regards,
> > Rudy Wieser
>
> A tray icon has its own tooptip control which is managed by the shell.
i.e.
> out of the owner application process. Even if you manage to get its
tooltip
> control window handle, if you use TTM_UPDATETIPTEXT, the pointer to the
> TOOLINFO structure including all of the pointers in the structure fields
> point to address space in your application process, not the shell
process'.
> i.e. the shell process will try to read data which isn't there.
>
> Also, WM_GETTEXT/WM_SETTEXT don't work on tooltip controls.
>
> I don't think we can update a tooltip text and make it show the net text
> while the tooltip control is being shown. IME, I'd have to redisplay it in
> order to make the new text take into effect visually (e.g. to show a time
> duration in realtime). Note that this would cause flickering on the
tooltip
> control itself.
>
> I haven't tried it yet, but try InvalidateRect() the tooltip window after
> changing the tray's tooltip text via Shell_NotifyIcon(). Assuming that
> tooltip control doesn't cache the text before displaying its window.
>
> The other alternative method is to use window hook which is hacky. It'll
> also solve the WM_COPYDATA and shared memory issues. But I recall you're
not
> a fan of hacky ways.


0
R
12/8/2016 1:01:01 AM
On Thu, 8 Dec 2016 09:28:40 +0100, R.Wieser wrote:
> Hello all,
> 
> I've put an icon in the SysTray and given it a tooltip text.  Hovering over
> the icon displays the tooltip nicely.
> 
> I can also update the tooltip text, but only when the mouse moves off and
> than on the icon again the new tooltip is shown.
> 
> Question : how do I change the shown tooltip text dynamically ?
> 
> I've been able to get the handle to the tooltip itself, but a WM_SETTEXT
> seems to be ignored, and sending a TTM_UPDATETIPTEXT message crashes the
> target app (most likely because the provided record is in memory not
> readable by the target process).
> 
> WM_COPYDATA seems to be unusable both because the target app has no idea
> what to do with it as well as the TOOLINFO structure containing a pointer to
> some text (the stuff I want to have displayed :-) ), which is not permitted
> when using WM_COPYDATA.
> 
> I've been thinking about using shared memory, but as that works with handles
> and the target app expects a simple memory reference I don't think thats
> going to work either ...
> 
> Regards,
> Rudy Wieser

A tray icon has its own tooptip control which is managed by the shell. i.e.
out of the owner application process. Even if you manage to get its tooltip
control window handle, if you use TTM_UPDATETIPTEXT, the pointer to the
TOOLINFO structure including all of the pointers in the structure fields
point to address space in your application process, not the shell process'.
i.e. the shell process will try to read data which isn't there.

Also, WM_GETTEXT/WM_SETTEXT don't work on tooltip controls.

I don't think we can update a tooltip text and make it show the net text
while the tooltip control is being shown. IME, I'd have to redisplay it in
order to make the new text take into effect visually (e.g. to show a time
duration in realtime). Note that this would cause flickering on the tooltip
control itself.

I haven't tried it yet, but try InvalidateRect() the tooltip window after
changing the tray's tooltip text via Shell_NotifyIcon(). Assuming that
tooltip control doesn't cache the text before displaying its window.

The other alternative method is to use window hook which is hacky. It'll
also solve the WM_COPYDATA and shared memory issues. But I recall you're not
a fan of hacky ways.
0
JJ
12/8/2016 1:32:21 PM
R.Wieser a �crit :
> Hello all,
>
> I've put an icon in the SysTray and given it a tooltip text.  Hovering over
> the icon displays the tooltip nicely.
>
> I can also update the tooltip text, but only when the mouse moves off and
> than on the icon again the new tooltip is shown.
>
> Question : how do I change the shown tooltip text dynamically ?

The simplest way is with NIM_MODIFY and NIIF_USER flags, which will show 
a Balloon type Tooltip without user interaction
(usually 16*16 for hIcon)


0
Christian
12/8/2016 4:21:24 PM
Christian,

> which will show a Balloon type Tooltip without user interaction

The idea was to have info displayed *only* when the user wants to see it,
not as a forced distraction.  As the tooltip is already available I thought
it would be a good idea to use it.

But alas, it seems to be designed to twart any attempt to do something even
slightly different with it ... :-(

Regards,
Rudy Wieser


-- Origional message:
Christian Astor <castorix@club-internet.fr> schreef in berichtnieuws
o2c1ac$qdu$1@gioia.aioe.org...
> R.Wieser a �crit :
> > Hello all,
> >
> > I've put an icon in the SysTray and given it a tooltip text.  Hovering
over
> > the icon displays the tooltip nicely.
> >
> > I can also update the tooltip text, but only when the mouse moves off
and
> > than on the icon again the new tooltip is shown.
> >
> > Question : how do I change the shown tooltip text dynamically ?
>
> The simplest way is with NIM_MODIFY and NIIF_USER flags, which will show
> a Balloon type Tooltip without user interaction
> (usually 16*16 for hIcon)
>
>


0
R
12/8/2016 5:04:37 PM
Reply: