Bubble help over an area
Bubble help over an area
Last question for a while.
Is it possible to have a help bubble come up over a certain area when the mouse pointer has been moved over it?
Either RMB or just move over the area.
Bit tough this one.
Is it possible to have a help bubble come up over a certain area when the mouse pointer has been moved over it?
Either RMB or just move over the area.
Bit tough this one.
Mmmm not quite
Having trouble getting "ToolBarToolTip()" to work.
Sorry only a Newbie.
Sorry only a Newbie.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
The following creates a tooltip control (Windows only) and adds two tools corresponding to a 20x20 pixel area at the top left of the window and another one at the bottom right etc.
Code: Select all
Global TT
Procedure.l callback(hwnd, uMsg, wParam, lParam)
Static text$
Result = #PB_ProcessPureBasicEvents
If uMsg = #WM_MOUSEMOVE
msg.MSG
msg\hwnd = hwnd
msg\message = uMsg
msg\wParam = wParam
msg\lParam = lParam
SendMessage_(TT, #TTM_RELAYEVENT, 0,msg)
EndIf
If uMsg = #WM_NOTIFY
*nmh.NMHDR=lParam
If *nmh\code = #TTN_NEEDTEXT
*tt.TOOLTIPTEXT=lParam
text$="From tool "+Str(*tt\hdr\idFrom)
*tt\lpszText=@text$
EndIf
EndIf
ProcedureReturn Result
EndProcedure
OpenWindow(0, 0, 0, 300, 300, "Tooltips by area",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
TT = CreateWindowEx_(0, "Tooltips_Class32", "", #TTS_ALWAYSTIP|#TTS_BALLOON, 0, 0, 0, 0, 0, 0, 0, 0)
SendMessage_(TT, #TTM_SETTITLE, 1, "HiYa")
SendMessage_(TT, #TTM_SETMAXTIPWIDTH, 0, 250)
;Add two 'tools' by area; one in the top left of the window and one in the bottom right.
ti.TOOLINFO\cbSize = SizeOf(TOOLINFO)
ti\uFlags = #TTF_CENTERTIP
ti\hwnd = WindowID(0)
ti\lpszText = #LPSTR_TEXTCALLBACK
;Top left.
SetRect_(@ti\rect, 0,0,20,20)
;Register tooltip with the control
SendMessage_(TT, #TTM_ADDTOOL, 0, ti)
;Bottom right.
ti\uId = 1
SetRect_(@ti\rect, 280,280,300,300)
;Register tooltip with the control
SendMessage_(TT, #TTM_ADDTOOL, 0, ti)
;A callback is needed
SetWindowCallback(@callback())
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
End
I may look like a mule, but I'm not a complete ass.
- Michael Vogel
- Addict
- Posts: 2798
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
What a cool example - thanks srod
But that's not all I want to say
... of course, I have also a small problem with the code:
What have to be done to keep the tooltips at top - I am using it in a window which is also on the top (StickyWindows) and this lousy window is in front of the tooltip frame.
Any idea what I did wrong?

But that's not all I want to say

What have to be done to keep the tooltips at top - I am using it in a window which is also on the top (StickyWindows) and this lousy window is in front of the tooltip frame.
Any idea what I did wrong?
Aye, using StickyWindow() !Any idea what I did wrong?

You may have to use SetWindowPos_() on the tooltip control just after it is shown. There's probably some notification somewhere which will help out. Failing that - do you really need a sticky window? You can use SetWindowPos_() instead on the window with the #HWND_TOP flag, it is not quite as severe as StickyWindow() which utilises the #HWND_TOPMOST flag.
**EDIT : here you are. When creating the tooltip control specify the parent window to be the sticky window etc.
Code: Select all
TT = CreateWindowEx_(0, "Tooltips_Class32", "", #TTS_ALWAYSTIP|#TTS_BALLOON, 0, 0, 0, 0, WindowID(0), 0, 0, 0)
I may look like a mule, but I'm not a complete ass.
- Michael Vogel
- Addict
- Posts: 2798
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Thanks, srod!srod wrote:Code: Select all
TT = CreateWindowEx_(0, "Tooltips_Class32", "", #TTS_ALWAYSTIP|#TTS_BALLOON, 0, 0, 0, 0, WindowID(0), 0, 0, 0)
Now it works nice (deleted my SetWindowPos_ already, see below :roll:) and is a fine, short - and working - code!
I thought, StickyWindows will do exactly the same like SetWindowPos, so I didn't feal bad

A feel a little bit more uncomfortable with my SendMessage() line in the Callback routine, can you give me a nice hint for that as well?
Code: Select all
Global InfoText.s
Global InfoID
Global InfoMessage.MSG
Global *InfoStruct.NMHDR
Global *InfoText.TOOLTIPTEXT
Global Callback
Global OnTop=#True
Procedure Callback(WindowID,Message,wParam,lParam)
Select Message
Case #WM_SYSCOMMAND
If wParam=#SC_MAXIMIZE
Callback=1
ProcedureReturn 0
EndIf
Case #WM_MOUSEMOVE
InfoMessage\hwnd=WindowID
InfoMessage\message=Message
InfoMessage\wParam=wParam
InfoMessage\lParam=lParam
SendMessage_(InfoID,#TTM_RELAYEVENT,0,InfoMessage)
Case #WM_NOTIFY
*InfoStruct=lParam
If *InfoStruct\code=#TTN_NEEDTEXT
*InfoText=lParam
z=*InfoText\hdr\idFrom
SendMessage_(InfoID,#TTM_SETTITLE,z%4,"Icon")
InfoText="Text "+Str(z)
*InfoText\lpszText=@InfoText
EndIf
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
xsize=300
ysize=200
Anzahl=8
OpenWindow(0,40,40,xsize,ysize," Michael Vogel's Ping Utility ",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget |#PB_Window_MaximizeGadget)
InfoID=CreateWindowEx_(0,"Tooltips_Class32","",#TTS_ALWAYSTIP|#WS_EX_TOPMOST,0,0,0,0,WindowID(0),0,0,0);#TTS_BALLOON
;InfoID=CreateWindowEx_(0,"Tooltips_Class32","",#TTS_ALWAYSTIP|#WS_EX_TOPMOST|#TTS_BALLOON,0,0,0,0,0,0,0,0)
SendMessage_(InfoID,#TTM_SETMAXTIPWIDTH,0,200)
SendMessage_(InfoID,#TTM_SETTITLE,1,"SNMP Informationen")
InfoTool.TOOLINFO
InfoTool\cbSize=SizeOf(TOOLINFO)
InfoTool\uFlags=#TTF_CENTERTIP
InfoTool\hwnd=WindowID(0)
InfoTool\lpszText=#LPSTR_TEXTCALLBACK
CreateGadgetList(WindowID(0))
For i=1 To Anzahl
TextGadget(i,0,20*i,200,18,"Icon "+Str(i%4)+", Text "+Str(i),#PB_Text_Border)
InfoTool\uId=i
SetRect_(@InfoTool\rect,0,20*i,200,20*i+18)
SendMessage_(InfoID,#TTM_ADDTOOL,0,InfoTool)
Next i
StickyWindow(0,OnTop)
;SetWindowPos_(InfoID,#HWND_TOPMOST,0,0,0,0,#SWP_NOREDRAW|#SWP_NOMOVE|#SWP_NOSIZE); ****
SetWindowCallback(@callback(),0)
Define event.l
Repeat
Event=WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
exit=99
Case #WM_PAINT
; WriteAll()
EndSelect
If Callback
Callback=0
OnTop=1-OnTop
StickyWindow(0,OnTop); ****
EndIf
Until exit
Huiii - checked the program on an old notebook (WinXP) and a tooltip starts from transparent to not so transparent and before anything is really readable it fades away slowly, whats going on here

At least, the fade in is gone (with the following change) - but the fade out effect is still present

Code: Select all
#TTS_NOFADE=$20
#TTS_NOANIMATE=$10
InfoID=CreateWindowEx_(0,"Tooltips_Class32","",#TTS_ALWAYSTIP|#TTS_NOFADE|#TTS_NOANIMATE|#WS_EX_TOPMOST,0,0,0,0,0,0,0,0);#TTS_BALLOON
Added:
The actual state of my small Ping utility is here: http://sudokuprogram.googlepages.com/vping.zip
On the left side (IP-addresses) I use the tooltip to see the name and type of the device (if available)...
Still fighting with some issues: fading is still present (and slow) and changing the title with sendmessage means wrong titles from time to time...
- Michael Vogel
- Addict
- Posts: 2798
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact: