Since someone posted somewhere here the other day asking about a ToolTip type library, I thought I'd go ahead and take a moment to play around with something along those lines, as I way to get my mind distracted from the "bad handle" issue my other project keeps tossing me. Sometimes the brain just needs to switch gears and reset, so I thought I'd pass it something completely different to work on for a little bit. :)
RegisterToolTip "Cheese is tasty and made from moo moo cows!", 245, 100
RegisterToolTip "A fridge is the cold thing which folks hold their cheeses in!", 380, 100
_PRINTSTRING (100, 100), "People like cheese in their fridge ." DisplayToolTips
_LIMIT 30 'don't melt my damn CPU
SUB RegisterToolTip
(what$
, x
, y
) IF x
< 0 OR y
< 0 THEN EXIT SUB 'don't put your tooltip off the damn screen! IF RegisteredTips
(i
).text
= "" THEN 'it's a free tooltip spot RegisteredTips(i).text = what$
RegisteredTips(i).x = x
RegisteredTips(i).y = y
EXIT SUB 'We're done. We've registered! 'If we make it to here, we failed. Some dummy probably has more than 100 tooltips, or else they registered them inside a loop, or such.
'(Note, this dummy could be your's truly...)
IF RegisteredTips
(i
).x
= x
AND RegisteredTips
(i
).y
= y
THEN 'it's a free tooltip spot RegisteredTips(i).text = ""
RegisteredTips(i).x = -1
RegisteredTips(i).y = -1
EXIT SUB 'We're done. We've registered!
IF RegisteredTips
(i
).text
<> "" THEN _PUTIMAGE (RegisteredTips
(i
).x
, RegisteredTips
(i
).y
), Qbox
'show that damn tool tip
CLS , _RGB32(255, 255, 255) 'white background _PUTIMAGE (RegisteredTips
(i
).x
, RegisteredTips
(i
).y
- h
), temp
There's a million different ways to do one of these, but I chose one of the simplest just to kinda highlight the process behind them. At their heart, they're nothing more than a little routine which "designates proper coordinate for the mouse to be at to generate a pop up", "check to see if the mouse is in those coordinates", "if so, then pop up something!"
For this to be a proper little routine, it needs some work on positioning of the tooltip (right now, you can pop it up with portions -- or even the whole thing -- completely offscreen), but it's basically the process one would use for this type of job.
It could also use a slightly smarter detection method, and background storage/replacement, but those are "advanced" features, and just complicate the basics which is what I really wanted to show here. ;)
Anywho, it is what it is. Maybe it'll be enough for a start to help someone sort out how they'd want to implement something similar in their own programs. :)