Shoutbox

[Resource] ToolTip Class (Updated: 14/08/07) - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Resource] ToolTip Class (Updated: 14/08/07) (/showthread.php?tid=70388)

[Resource] ToolTip Class (Updated: 14/08/07) by Eljay on 01-06-2007 at 06:18 PM

ToolTip Class 2.0
Now: Without a dll!

Well, I finally got around to updating this, with a little nagging from Mattike :P


Change log:

Only two noticable differences from the first version:
  • No more _ToolTip.dll! - Thanks to Patchou changing the number of parameters allowed with Interop.Call from 9 to 12, I no longer need to use a dll to create the tooltip window!
  • ToolTip.Destroy(); - Just a new function that "does what it says on the tin", destroys the tooltip!

Example Usage:
code:
// Create your window.
var MyWindow = MsgPlus.CreateWnd('MyWindow.xml', 'MyWindow');
// Get a handle to the button
var MyButton = MyWindow.GetControlHandle("ExampleButton");
// Create the ToolTip window
var MyToolTip = new ToolTip(MyButton, "Text on tooltip", "ToolTip Title", TTI_INFO);

// Update the title of the tooltip
MyToolTip.Title = "New ToolTip Title";
MyToolTip.UpdateToolTip();


[Image: ToolTipExample.gif]


List of icon constants:
  • TTI_NONE
  • TTI_INFO
  • TTI_WARNING
  • TTI_ERROR
  • TTI_INFO_LARGE
  • TTI_WARNING_LARGE
  • TTI_ERROR_LARGE
  • Any HICON aquired through LoadIcon

Download ToolTip Class now!

RE: [Resource] ToolTip Class by hmaster on 01-06-2007 at 06:25 PM

Good stuff, working perfectly :).


RE: [Resource] ToolTip Class by Thor on 01-06-2007 at 06:25 PM

Looks good, don't have the time to test it :P

But yes, it looks really good. (Y) A nice resource.


(Btw, there should have been it's own resource page at msgpluslive.net for developers :))


RE: [Resource] ToolTip Class by matty on 01-06-2007 at 06:26 PM

Good job!


RE: [Resource] ToolTip Class by Dempsey on 01-06-2007 at 06:32 PM

quote:
Originally posted by Nitro

(Btw, there should have been it's own resource page at msgpluslive.net for developers :))
this is the sort of thing I'm going to put on mpscripts.net
RE: [Resource] ToolTip Class by the andyman on 01-06-2007 at 06:49 PM

Good work. I'm sure I'll be using this in the future :P


RE: [Resource] ToolTip Class by hmaster on 01-06-2007 at 07:33 PM

Submit it here : http://www.msgpluslive.net/scripts/browse/9/Others/ ?


RE: [Resource] ToolTip Class by deAd on 01-06-2007 at 10:03 PM

Looks good (y)


RE: [Resource] ToolTip Class by Chestah on 01-06-2007 at 10:46 PM

Nice work eljay - i might use this in some of my scripts! Thanks for the explanation too - unfortunately you missed a bit. How do i extract the files out of the zip file :P


RE: [Resource] ToolTip Class by Matti on 01-07-2007 at 08:34 AM

Damned... I'm trying to let my interface XML's change their tooltips to make my script multilingual and then you have to do this... :'(

Naah, great work! I'm definitely going to use it! :)

PS: Do we have to register _ToolTip.dll, and if so, do we have to register it in the DotNetFiles or the OleFiles? :P


RE: [Resource] ToolTip Class by Felu on 01-07-2007 at 08:41 AM

Nice work [Image: msn_up.gif]. I might use it in my scripts.


RE: [Resource] ToolTip Class by Eljay on 01-07-2007 at 08:47 AM

quote:
Originally posted by Mattike
PS: Do we have to register _ToolTip.dll, and if so, do we have to register it in the DotNetFiles or the OleFiles? :P

Neither, it's just a standard dll.
RE: [Resource] ToolTip Class by Matti on 01-07-2007 at 09:41 AM

quote:
Originally posted by Eljay
Neither, it's just a standard dll.
Okay, I just thought it could be necessary and I'd have trouble when I wouldn't register... thanks for telling! :)
RE: [Resource] ToolTip Class by the andyman on 01-08-2007 at 05:05 PM

Does this only work on buttons or can it be on thing like text and check boxes too?


RE: [Resource] ToolTip Class by Eljay on 01-08-2007 at 05:09 PM

quote:
Originally posted by the andyman
Does this only work on buttons or can it be on thing like text and check boxes too?

Anything.
RE: [Resource] ToolTip Class by Matti on 01-08-2007 at 05:10 PM

quote:
Originally posted by Eljay
Anything.
...that can have a <Help> child, right? :P
RE: [Resource] ToolTip Class by CookieRevised on 01-08-2007 at 05:12 PM

quote:
Originally posted by Mattike
quote:
Originally posted by Eljay
Anything.
...that can have a <Help> child, right? :P
nope... this class doesn't have anything todo with that (Plus!'s interface <help> tag, which will create a standard tooltip).

This class creates its own tooltip windows and can be used on anything which has a window handle. The class is nice, but in most cases (all?) you don't need a title and icon for a tooltip, so there is no use in using this class if you just want standard normal tooltips.

The class is usefull if you want to add a very big explanation or whatever where using a title and icon makes some sense.

Aka: don't use this class (and mandatory DLL!) for just simply adding a tooltip to some control. It would be extremely overdoing it and bloating your code serisouly (much code in your script in that case for something rather non-functional and which can be done way more easier). In that case use the build in Plus! interface tag <help>.
RE: [Resource] ToolTip Class by Matti on 01-08-2007 at 05:26 PM

quote:
Originally posted by CookieRevised
nope... this class doesn't have anything todo with that (Plus!'s interface <help> tag, which will create a real tooltip).

This class creates its own tooltip windows.
Hmm... but it's using the Windows API message "TTM_ADDTOOL" to actually create it, right? Let me check MSDN...

Right, MSDN just says it registers a tooltip for a control, but can it be used on an element too? Like, let's say, can you use TTM_ADDTOOL to create a tooltip for an ImageElement? ^o)

Aargh, I'll STFU! You're right, it can be used on any control whose handle can be returned by PlusWnd.GetControlHandle. I should've analyzed the code better. :P
RE: [Resource] ToolTip Class by Flash on 02-24-2007 at 10:51 PM

code:
MyToolTip.Text = "...";
MyToolTip.Icon = TTI_INFO;
MyToolTip.Title = "...".


this work? because i try and that not work

code:
var MyToolTip0 = new ToolTip(MyButton, "Select a picture in this list for associate them to the status.", name, TTI_INFO)
        Debug.Trace("ToolTip: " +MyToolTip0)

that return
code:
ToolTip: [object Object]


RE: [Resource] ToolTip Class by Flash on 03-18-2007 at 05:59 PM

ok this plugins work perfectly ;)

just need to update the tooltip after edit them

code:
MyToolTip[0].Text = "You want to set this\npicture to this Ps?"
MyToolTip[0].Title = Wnd.GetControlText("LblName")
MyToolTip[0].UpdateToolTip();

RE: [Resource] ToolTip Class by Eljay on 03-18-2007 at 09:00 PM

Yeh I kind of forgot to mention that in the first post, I've added it now thanks for pointing it out. :)


RE: [Resource] ToolTip Class by Matti on 08-10-2007 at 04:48 PM

I'm having a problem with the class. When I try to use UpdateToolTip, it doesn't update the text. The title and icon get updated succesfully, but the text doesn't change. Could someone help me?


RE: [Resource] ToolTip Class (Updated: 14/08/07) by Eljay on 08-14-2007 at 04:06 PM

Finally updated this, see first post for details.

Please confirm that UpdateToolTip works properly now Mattike :P


RE: [Resource] ToolTip Class (Updated: 14/08/07) by Matti on 08-14-2007 at 04:15 PM

Many many many thanks for this, Eljay! :D
Works great, and the UpdateToolTip() finally functions properly. :)


RE: [Resource] ToolTip Class (Updated: 14/08/07) by Flash on 09-13-2007 at 02:43 AM

hum allo? I can do this to work?
MyToolTip.Text() = MyToolTip.Text+ '\n'+Text;


i think in find a bug, hold your mouse on the button and the tooltip desapear for all time.



quote:
Originally posted by Flash
hum allo? I can do this to work?
MyToolTip.Text() = MyToolTip.Text()+ '\n'+Text;

http://www.gamedev.net/community/forums/topic.asp?topic_id=107920
that say we can use GETTEXT for get the text tooltip
RE: [Resource] ToolTip Class (Updated: 14/08/07) by Matti on 09-13-2007 at 03:26 PM

You're doing it wrong. :P

code:
var MyToolTip = new Tooltip(...) //Just to make sure you know that MyToolTip is a ToolTip class. :P
//MyToolTip::Text is a property of the type String, so you don't need the brackets there. Besides, you can't place function calls on the left side anyway!!!
//So here are 2 ways to do it, a "long" method and a "short" one. :)

MyToolTip.Text = MyToolTip.Text + "\n" + Text; //Method 1
MyToolTip.Text += "\n" + Text; //Method 2
//And finally, you need to call UpdateToolTip to update the tooltip. ;)
MyToolTip.UpdateToolTip();
//That's it! :P


RE: [Resource] ToolTip Class (Updated: 14/08/07) by Flash on 09-14-2007 at 09:46 AM

quote:
Originally posted by Mattike
You're doing it wrong. :P
code:
var MyToolTip = new Tooltip(...) //Just to make sure you know that MyToolTip is a ToolTip class. :P
//MyToolTip::Text is a property of the type String, so you don't need the brackets there. Besides, you can't place function calls on the left side anyway!!!
//So here are 2 ways to do it, a "long" method and a "short" one. :)

MyToolTip.Text = MyToolTip.Text + "\n" + Text; //Method 1
MyToolTip.Text += "\n" + Text; //Method 2
//And finally, you need to call UpdateToolTip to update the tooltip. ;)
MyToolTip.UpdateToolTip();
//That's it! :P


ok thx that work fine now, but u see my little bug?
RE: [Resource] ToolTip Class (Updated: 14/08/07) by matty on 09-14-2007 at 11:16 AM

quote:
Originally posted by Flash

ok thx that work fine now, but u see my little bug?
It's not a bug when you are doing it wrong.
RE: [Resource] ToolTip Class (Updated: 14/08/07) by Flash on 09-14-2007 at 10:52 PM

quote:
Originally posted by matty
quote:
Originally posted by Flash

ok thx that work fine now, but u see my little bug?
It's not a bug when you are doing it wrong.
what is wrong in that HUH?
code:
var MyToolTip = new Array()
function CrtToolTip(w,id,Text) {
    var b = w.GetControlHandle(id);
    if (MyToolTip[b] == null) {
        MyToolTip[b] = new ToolTip(b,"Save every setting and Quit.\nChange(s):\n" +Text, "Save&Quit", TTI_INFO);
    }
    else {
        MyToolTip[b].Text += '\n'+Text;
        MyToolTip[b].UpdateToolTip();
    }
}


if i hold my mouse on the button 10 secondes, the tip desapear and i try to repass my mouse on the button but nothing Appear so i need to recreate the tip.

Its a bad setting whit your variable?
RE: [Resource] ToolTip Class (Updated: 14/08/07) by Flash on 09-16-2007 at 12:11 PM

hum hello? i find a real bug pls repond me how to change this.

i dont want to create a timer for recreate the Tip :|


RE: [Resource] ToolTip Class (Updated: 14/08/07) by Dempsey on 09-16-2007 at 08:41 PM

isn't that just how tooltips work?  they disappear after a short time?


RE: [Resource] ToolTip Class (Updated: 14/08/07) by Flash on 09-16-2007 at 11:13 PM

i dont know but if desapear automaticaly when i hold my mouse on he not reappear after repass my mouse on i need to upgrade the tooltip


RE: [Resource] ToolTip Class (Updated: 14/08/07) by SmokingCookie on 07-15-2008 at 06:52 AM

Hi,

I know it's a bit late, but would it be possible for you to make a "balloon" pop-up, like in Windows Vista? (see screenshot).

[Image: screenzb4.th.jpg]


RE: [Resource] ToolTip Class (Updated: 14/08/07) by tribbium on 07-21-2009 at 08:36 AM

Hi,

I know it's a bit late, but it is possible for it to be a ballon pop-up.

In _ToolTip.js replace

code:
var TTS_NOPREFIX = 0x2;

with

code:
var TTS_NOPREFIX = 64;

note that this is definitely a hack but it'll work. If you really feel the need to, make a new variable

code:
var TTS_BALLOON = 64;

and replace every instance of TTS_NOPREFIX with TTS_BALLOON instead.
RE: [Resource] ToolTip Class (Updated: 14/08/07) by SmokingCookie on 07-21-2009 at 03:23 PM

Hi,

Thanks for the answer. I am currently in France though, so I,ll check it out when I am back home.

[offtopic]The weather is bad here so I guess I will be before the end of the week :(

And those AZERTY keyboards are weird![/offtopic]


RE: [Resource] ToolTip Class (Updated: 14/08/07) by V@no on 08-28-2010 at 10:57 PM

I can't seem to get this working on StaticControl type controls (aka simple text).

Any suggestions?
Thank you.


RE: [Resource] ToolTip Class (Updated: 14/08/07) by Matti on 08-29-2010 at 06:57 PM

quote:
Originally posted by V@no
I can't seem to get this working on StaticControl type controls (aka simple text).

Any suggestions?
Thank you.
Win32 Tooltips can only be attached to controls which expose a HWND. Labels don't have a HWND type property, so you can't pass it in the TOOLINFO structure to TTM_ADDTOOL.

You could cheat though, by listening to WM_MOUSEMOVE on the window and detecting when the mouse hovers the label. When this happens, you'd assign a tooltip to the window instead of the label. When the mouse goes out of the label rectangle again, you'd remove the tooltip from the window. As you may have guessed, this is considered to be a pretty nasty workaround. :P