I can set and change tooltips on any gadgets without problems most of the time.
In a listicongadget that I have, I get the current line being clicked on and change the tooltip text to the contents of that line.
It seems to randomly crash the compiler with a "ERROR: Stack Overflow" and it doesn't seem to matter whether I click fast or slow on each line. It also doesn't matter what sorts of gadgets I use. Start clicking and random stack overflow crashes occur.
Anyone else have experience with this?
Code: Select all
;============================================================================================================================
; Personal balloon tooltip window, colourful and not boring at all
;============================================================================================================================
Procedure MyBalloonToolTips(btWindow.l, btGadget.l, btText.s)
ForEach tooltips() ; Exit this routine if tool tip for control exists
If tooltips()\window = btWindow And tooltips()\gadget = btGadget
ProcedureReturn
EndIf
Next
;--------------------------------------------------------------------------------------------------------------------
ToolTipControl = CreateWindowEx_(0, "ToolTips_Class32", "", #WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON, 0, 0, 0, 0, WindowID(btWindow), 0, GetModuleHandle_(0), 0)
SetWindowPos_(ToolTipControl,#HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE)
SendMessage_(ToolTipControl, #TTM_SETTIPTEXTCOLOR, 0, 0)
SendMessage_(ToolTipControl, #TTM_SETTIPBKCOLOR, $F58C0A, 0)
SendMessage_(ToolTipControl, #TTM_SETMAXTIPWIDTH, 0, 380)
Button.TOOLINFO\cbSize = SizeOf(TOOLINFO)
Button\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS
Button\hwnd = WindowID(btWindow)
Button\uID = GadgetID(btGadget)
Button\hInst = 0
Button\lpszText = @btText
SendMessage_(ToolTipControl, #TTM_ADDTOOL, 0, Button)
SendMessage_(ToolTipControl, #TTM_UPDATE, 0, 0)
;--------------------------------------------------------------------------------------------------------------------
AddElement(tooltips()) ; Add the newly created tool tip details to the linked list
tooltips()\window = btWindow
tooltips()\gadget = btGadget
tooltips()\handle = ToolTipControl
EndProcedure
; MyBalloonToolTips(#MyMainWindow, #MyListIconGadget, "This will be the primary tool tip text")
;============================================================================================================================
; With this routine, I can change the tool tip text at any time. I do this throughout the program as I have a default too
; tip and then a dynamically changing tool tip on some gadgets depending on their fields.
;============================================================================================================================
;============================================================================================================================
; The routine allows you to change the tool tip text for a specific gadget
;============================================================================================================================
Procedure.l ChangeToolTip(ttGadget.l, btText.s)
ForEach tooltips() ; Check each tooltip entry
If tooltips()\gadget = ttGadget.l And IsGadget(ttGadget.l) ; If there is an entry in the list for this window
btHandle.l = tooltips()\handle ; Get the current tooltip handle
btWindow.l = tooltips()\window ; Get the current window handle
btGadget.l = tooltips()\gadget ; Get the current gadget handle
ttChange.TOOLINFO\cbSize = SizeOf(TOOLINFO)
ttChange\hwnd = WindowID(btWindow.l)
ttChange\uId = GadgetID(btGadget.l)
ttChange\lpszText = @btText.s
SendMessage_(btHandle.l, #TTM_UPDATETIPTEXT, 0, ttChange)
EndIf
Next tooltips()
EndProcedure
; ChangeToolTip(#MyListIconGadget, "This is the new tool tip text")
;============================================================================================================================
; Remove previously set tool tips for an entire window. Xombie
;============================================================================================================================
Procedure.l RemoveToolTipW(TtWindow.l)
ForEach tooltips() ; Check each tooltip entry
If tooltips()\window = TtWindow.l ; If there is an entry in the list for this window
btHandle.l = tooltips()\handle ; Get the current tooltip handle
btWindow.l = tooltips()\window ; Get the current window handle
btGadget.l = tooltips()\gadget ; Get the current gadget handle
DeleteElement(tooltips()) ; Delete the current element from the list
Button.TOOLINFO\cbSize = SizeOf(TOOLINFO) ; Get tooltip info size
Button\hwnd = WindowID(btWindow) ; Get the windows id for this element
Button\uID = GadgetID(btGadget) ; Get the gadget id for this element
SendMessage_(btHandle, #TTM_DELTOOL, 0, Button) ; Delete the tooltip for this window from the list and gadget
EndIf ; End conditional test
Next ; Next iteration
EndProcedure