Page 1 of 1

More cohesive balloon tooltip usage

Posted: Sun Jun 17, 2007 8:20 am
by Fangbeast

Code: Select all

;============================================================================================================================
; In an effort to understand all the various balloon tool tip codes and ways of using them, I have evolved the current 
; procedures for myself to make them as useful as possible. There are an awful lot of people who have posted this sort
; of code in the forums and it's impossible to know who invented it first, did it better but they all did it free and it
; makes our code look better!!!
;
; Xombie, _Paul_, Srod, Sparkie, NetMaestro and loads of others
;
; Note, this tool tip type allows you to use "Chr(13) + Chr(10)" to manually format your tips to multiple lines.
;
; Hope that someone has a use for this.
;
;============================================================================================================================
; Create a structure used to track our balloon tool tip elements used by the various procedures
;============================================================================================================================

Structure tooltipdata                                                   ; If any tooltips setup, keep track of gadgets that have them so you can remove them if needed
  window.l
  gadget.l
  handle.l
EndStructure

;============================================================================================================================
; Create the linked list needed to keep track of all the different tool tips based on the structure above
;============================================================================================================================

Global NewList tooltips.tooltipdata()                                   ; All tool tip handles and data here

;============================================================================================================================
; Procedural declarations in case you store these all over the place
;============================================================================================================================

Declare   MyBalloonToolTips(btWindow.l, btGadget.l, btText.s)
Declare.l RemoveToolTip(btGadget.l)
Declare.l RemoveToolTipW(TtWindow.l)
Declare.l ChangeToolTip(ttGadget.l, btText.s)

;============================================================================================================================
; The routine below allows you to create a colourful balloon tool tip for every gadget in your system. You can assign each
; and every gadget its' own tooltip and keep track of them in a linked list
;
; Command:  MyBalloonToolTips(#TheWindowConstant, #TheGadgetConstant, TheToolTipText)
;
; When you send this command to the procedure:
;
;   1. It first checks to see if the gadget currently exists and exits if it doesn't.
;   2. Checks to see if the gadget already has a tool tip entry and exits the procedure if it does,
;   3. Creates the tool tip entry for the gadget
;   4. Add the details to the linked list for this tool tip entry (Window, Constant, Tool tip text)
;
;============================================================================================================================

Procedure MyBalloonToolTips(btWindow.l, btGadget.l, btText.s)

  If IsGadget(btGadget.l)                                                ; Does the gadget actually exist at this time?

    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)        ; Tool tip background colour used
    SendMessage_(ToolTipControl, #TTM_SETMAXTIPWIDTH, 0, 180)

    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

  EndIf

EndProcedure

;============================================================================================================================
; The routine below allows you to remove a previously set tool tip from a particular gadget.
;
; Command:  RemoveToolTip(#TheGadgetConstant)
;
; Before the gadget tool tip is removed from the linked list, it is checked for validity to avoid crashes or illegal memory
; errors.
;
;============================================================================================================================

Procedure.l RemoveToolTip(btGadget.l)

  ForEach tooltips()                                                    ; Remove each tool tip that exists for a control

    If tooltips()\gadget = btGadget.l And IsGadget(tooltips()\gadget)   ; Is there a stored entry and does the gadget exist?

      btHandle.l = tooltips()\handle
      btWindow.l = tooltips()\window

      DeleteElement(tooltips())                                         ; Delete the entry from the linked list

      Button.TOOLINFO\cbSize  = SizeOf(TOOLINFO)
      Button\hwnd             = WindowID(btWindow)
      Button\uID              = GadgetID(btGadget)

      SendMessage_(btHandle, #TTM_DELTOOL, 0, Button)                   ; Delete the tool tip from the gadget

      Break

    EndIf

  Next

EndProcedure 

;============================================================================================================================
; The routine below allows you to remove all tool tips for all gadgets from a specified window without having to specify
; each gadget individually.
;
; Command:  RemoveToolTipW(#TheWindowConstant)
;
;   1.  The linked list is searched for all matching gadgets for the supplied window.
;   2.  The window is checked for validity (In case you used this command in the wrong place and the window didn't exist!
;   3.  The gadget itself is checked for validity in case you removed it somewhere else.
;
;============================================================================================================================

Procedure.l RemoveToolTipW(TtWindow.l)

  ForEach tooltips()                                                    ; Check each tooltip entry

    If tooltips()\window = TtWindow.l And IsWindow(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

      If IsGadget(btGadget.l)                                            ; Is the gadget valid and active?

        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
      
    EndIf                                                                ; End conditional test

  Next                                                                   ; Next iteration

EndProcedure 

;============================================================================================================================
; The routine below allows you to change the tool tip text for a specific gadget
;
; Command:  ChangeToolTip(#TheGadgetConstant, TheToolTipText)
;
;   If a matching gadget is found in the linked list and it is valid, the tool tip change is sent to it
;
;============================================================================================================================

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.)
      ttChange\lpszText = @hText.s

      SendMessage_(btHandle.l, #TTM_UPDATETIPTEXT, 0, @btText.s)

    EndIf

  Next tooltips()

EndProcedure


Posted: Sun Jun 17, 2007 11:46 am
by srod
Nice one fangles. 8)

Thanks.

Posted: Sun Jun 17, 2007 12:41 pm
by Fangbeast
srod wrote:Nice one fangles. 8)

Thanks.
I'm only building on the work of you wizards. Couldn't code my way out of a paper bag myself!

Posted: Sun Jun 17, 2007 1:13 pm
by GeoTrail
99 luftballoon... tips :lol:

sorry, was bored ;)

Posted: Sun Jun 17, 2007 1:48 pm
by Fangbeast
GeoTrail wrote:99 luftballoon... tips :lol:

sorry, was bored ;)
Funny, I just played Nene's video clip the other day. Another one hit wonder. But I liked it.

Posted: Sun Jun 17, 2007 2:07 pm
by utopiomania
Thanks for posting this, but I can't get it to work with XP skin support enabled.

I posted balloon tooltip code myself in tips & tricks, but it had problems with
multiple tips appearing if I called the procedure more than once to change the
text so I thought I should steal a little from you and fix it, but it has the same
problem.

The ballon style tooltips won't show at all, unless I uncheck 'Enable XP skins'
in compiler options ? Anyy idea whats wrong ??

EDIT: BTW, the code I try to fix is this:

Code: Select all

;PB4.02

enumeration
  #WIN
  #BTN1
  #BTN2
  #BTN3
  #BTN4
endEnumeration

;-declares
;
declare toolTip(win, id, type, style, icon, fColor, bColor, title.s, tip.s)
declare openMainWindow()

;-startRun
;
openMainWindow()

;-events
;
repeat
until waitWindowEvent() = #PB_EVENT_CLOSEWINDOW

;-endRun
;
end

;-procedures
;
procedure toolTip(win, id, type, style, icon , fColor, bColor, title.s, tip.s)
  ;adds a tooltip to id. type: 0 = ordinary, 1 = balloon. style: 0 = ordinary, 
  ;1 = center stem. icon: 0 = no icon, 1 = info, 2 = warn, 3 = error
  #TTS_ALWAYSTIP = $1

  flags =  #WS_POPUP | (#TTS_BALLOON * type)
  flags =  #WS_POPUP | #TTS_NOPREFIX | (#TTS_BALLOON * type)
	tt = createWindowEx_(0, "toolTips_class32", "", flags, 0, 0, 0, 0, 0, 0, 0, 0)
  ;in case 'win' is topmost
  setWindowPos_(tt, #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_NOACTIVATE) 

	TI.TOOLINFO\cbSize = sizeOf(TOOLINFO)
	TI\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS | (#TTF_CENTERTIP * style)
	TI\hWnd = windowId(win)
	TI\uId = gadgetId(id)
  TI\hInst = 0 
	TI\lpszText = @tip

  ;color. rgb() or getSysColor_(see #COLOR_ constants)
  if fColor
    ;set the tip text color, also the tip outline color for balloon tooltips
    sendMessage_(tt, #TTM_SETTIPTEXTCOLOR, fColor, 0)
  endIf
  if bColor
    ;set the tip background color
    sendMessage_(tt, #TTM_SETTIPBKCOLOR, bColor, 0)
  endIf
	;set as a multiline tooltip with wordwrap
	sendMessage_(tt, #TTM_SETMAXTIPWIDTH, 0, 400)
	;set the icon style and tip title
	sendMessage_(tt, #TTM_SETTITLE, icon, title)

	;register tooltip with the control
	sendMessage_(tt, #TTM_ADDTOOL, 0, TI)
  SendMessage_(tt, #TTM_UPDATE, 0, 0) 
endProcedure

procedure openMainWindow()
  openWindow(#WIN, 0, 0, 300, 300, "Tooltip Styles", #PB_WINDOW_SCREENCENTERED | #PB_WINDOW_SYSTEMMENU)
  if createGadgetList(windowId(#WIN))
    buttonGadget(#BTN1, 110, 40, 80, 20, "Button1")
    toolTip(#WIN, #BTN1, 0, 0, 1, 0, 0, "", "This is a boring old Tooltip")

    buttonGadget(#BTN2, 110, 100, 80, 20, "Button2")
    toolTip(#WIN, #BTN2, 0, 1, 1, 0, RGB(226, 255, 255), "Title", "Not that boring old Tooltip")

    buttonGadget(#BTN3, 110, 160, 80, 20, "Button3")
    toolTip(#WIN, #BTN3, 1, 0, 0, 0, RGB(226, 255, 255), "", "This is a multi line Tooltip This is a multi line Tooltip")

    buttonGadget(#BTN4, 110, 220, 80, 20, "Button4")
    toolTip(#WIN, #BTN4, 1, 1, 1, RGB(57, 120, 63), RGB(226, 255, 255), "This is:", "A centered Tooltip")
  endIf
endProcedure

Hmm

Posted: Sun Jun 17, 2007 2:22 pm
by Fangbeast
I did have an error in my code above that may explain it.

Code: Select all

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.)
      ttChange\lpszText = @hText.s
      SendMessage_(btHandle.l, #TTM_UPDATETIPTEXT, 0, @btText.s)
    EndIf
  Next tooltips()
EndProcedure
Change these two lines from:

Code: Select all

      ttChange\lpszText = @hText.s
      SendMessage_(btHandle.l, #TTM_UPDATETIPTEXT, 0, @btText.s)
to:

Code: Select all

      ttChange\lpszText         = @btText.s
      SendMessage_(btHandle.l, #TTM_UPDATETIPTEXT, 0, ttChange)

More fun with tool tips

Posted: Sun Jun 17, 2007 2:27 pm
by Fangbeast

Code: Select all

;===========================================================================================================================
;
; Add a single tool tip to the only ListIconGadget on the form and then change that tool tip from the contents of the cell
; that has been double left clicked on.
;
;===========================================================================================================================
; All constants
;============================================================================================================================

Enumeration 1                                                                 ; All constants
  #Window_mtttest
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  #Gadget_mtttest_fmain
  #Gadget_mtttest_items
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

;===========================================================================================================================
; Windows code
;============================================================================================================================

Procedure.l Window_mtttest()
  If OpenWindow(#Window_mtttest,65,71,400,500,"Double click on a line to change the tooltip",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
    If CreateGadgetList(WindowID(#Window_mtttest))
      Frame3DGadget(#Gadget_mtttest_fmain,0,0,400,500,"")
      ListIconGadget(#Gadget_mtttest_items,5,10,390,485,"Artist name",192,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        AddGadgetColumn(#Gadget_mtttest_items,1,"Band Name",192)
      HideWindow(#Window_mtttest,0)
      ProcedureReturn WindowID(#Window_mtttest)
    EndIf
  EndIf
EndProcedure

;===========================================================================================================================
; Balloon tool tip related declarations
;============================================================================================================================

Declare   MyBalloonToolTips(btWindow.l, btGadget.l, btText.s)
Declare.l RemoveToolTip(btGadget.l)
Declare.l RemoveToolTipW(TtWindow.l)
Declare.l ChangeToolTip(ttGadget.l, btText.s)

;===========================================================================================================================
; ListIconGadget routine declarations
;============================================================================================================================

Declare   GetColumnCount(Gadget.l)                                           ; Get the number of columns from a LisIconGadget
Declare   TrackListIconPos()                                                 ; Check the listicon in the import window and show combobox if cell selected

;============================================================================================================================
; Constants for the listicongadget row and column testing (srod)
;============================================================================================================================

#LVM_SUBITEMHITTEST             = #LVM_FIRST + 57
#LVM_GETSUBITEMRECT             = #LVM_FIRST + 56
#LVM_GETHEADER                  = #LVM_FIRST + 31

;============================================================================================================================
; Keep track of all program variables here
;============================================================================================================================

Structure programdata
  quit.l
EndStructure

;============================================================================================================================
; Create a structure used to track our balloon tool tip elements used by the various procedures
;============================================================================================================================

Structure tooltipdata                                                        ; If any tooltips setup, keep track of gadgets that have them so you can remove them if needed
  window.l
  gadget.l
  handle.l
EndStructure

;============================================================================================================================
; Create the linked list needed to keep track of all the different tool tips based on the structure above
;============================================================================================================================

Global NewList tooltips.tooltipdata(), program.programdata                   ; All tool tip handles and data here

Global PInfo.LVHITTESTINFO, temp.Point, rc.rect                              ; Constants for testing which cell was selected on a listicongadget (srod)

;============================================================================================================================
; The routine below allows you to create a colourful balloon tool tip for every gadget in your system. You can assign each
; and every gadget its' own tooltip and keep track of them in a linked list
;
; Command:  MyBalloonToolTips(#TheWindowConstant, #TheGadgetConstant, TheToolTipText)
;
; When you send this command to the procedure:
;
;   1. It first checks to see if the gadget currently exists and exits if it doesn't.
;   2. Checks to see if the gadget already has a tool tip entry and exits the procedure if it does,
;   3. Creates the tool tip entry for the gadget
;   4. Add the details to the linked list for this tool tip entry (Window, Constant, Tool tip text)
;
;============================================================================================================================

Procedure MyBalloonToolTips(btWindow.l, btGadget.l, btText.s)

  If IsGadget(btGadget.l)                                                ; Does the gadget actually exist at this time?

    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)        ; Tool tip background colour used
    SendMessage_(ToolTipControl, #TTM_SETMAXTIPWIDTH, 0, 180)

    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

  EndIf

EndProcedure

;============================================================================================================================
; The routine below allows you to remove a previously set tool tip from a particular gadget.
;
; Command:  RemoveToolTip(#TheGadgetConstant)
;
; Before the gadget tool tip is removed from the linked list, it is checked for validity to avoid crashes or illegal memory
; errors.
;
;============================================================================================================================

Procedure.l RemoveToolTip(btGadget.l)

  ForEach tooltips()                                                    ; Remove each tool tip that exists for a control

    If tooltips()\gadget = btGadget.l And IsGadget(tooltips()\gadget)   ; Is there a stored entry and does the gadget exist?

      btHandle.l = tooltips()\handle
      btWindow.l = tooltips()\window

      DeleteElement(tooltips())                                         ; Delete the entry from the linked list

      Button.TOOLINFO\cbSize  = SizeOf(TOOLINFO)
      Button\hwnd             = WindowID(btWindow)
      Button\uID              = GadgetID(btGadget)

      SendMessage_(btHandle, #TTM_DELTOOL, 0, Button)                   ; Delete the tool tip from the gadget

      Break

    EndIf

  Next

EndProcedure 

;============================================================================================================================
; The routine below allows you to remove all tool tips for all gadgets from a specified window without having to specify
; each gadget individually.
;
; Command:  RemoveToolTipW(#TheWindowConstant)
;
;   1.  The linked list is searched for all matching gadgets for the supplied window.
;   2.  The window is checked for validity (In case you used this command in the wrong place and the window didn't exist!
;   3.  The gadget itself is checked for validity in case you removed it somewhere else.
;
;============================================================================================================================

Procedure.l RemoveToolTipW(TtWindow.l)

  ForEach tooltips()                                                    ; Check each tooltip entry

    If tooltips()\window = TtWindow.l And IsWindow(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

      If IsGadget(btGadget.l)                                            ; Is the gadget valid and active?

        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
      
    EndIf                                                                ; End conditional test

  Next                                                                   ; Next iteration

EndProcedure 

;============================================================================================================================
; The routine below allows you to change the tool tip text for a specific gadget
;
; Command:  ChangeToolTip(#TheGadgetConstant, TheToolTipText)
;
;   If a matching gadget is found in the linked list and it is valid, the tool tip change is sent to it
;
;============================================================================================================================

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

;============================================================================================================================
; Check the listicon in the import window and show combobox if cell selected
;============================================================================================================================
;
; Get a specific cell on a specific line
; 
; btText.s = GetGadgetItemText(#Gadget_mtttest_items, pInfo\iItem, pInfo\iSubItem)
;
;----------------------------------------------------------------------------------------
;
; Get all cells on the line into a long string
;
; For AllCells = 0 To GetColumnCount(#Gadget_mtttest_items)
;
;  MainString.s + GetGadgetItemText(#Gadget_mtttest_items, pInfo\iItem, AllCells) + "|"
;
; Next AllCells
;
; SetClipboardText(MainString.s) ; Copy the text to the clipboard if you need it
;
;----------------------------------------------------------------------------------------
;
; Get all cells on the line into a long string with one item per line
;
; For AllCells = 0 To GetColumnCount(#Gadget_mtttest_items)
;
;   MainString.s + GetGadgetItemText(#Gadget_mtttest_items, pInfo\iItem, AllCells) + Chr(13) + Chr(10)
;
; Next AllCells
;
; SetClipboardText(MainString.s) ; Copy the text to the clipboard if you need it
;
;============================================================================================================================

Procedure TrackListIconPos()

  GetCursorPos_(temp)

  MapWindowPoints_(0, GadgetID(#Gadget_mtttest_items), temp, 1)

  pInfo\pt\x = temp\x

  pInfo\pt\y = temp\y

  SendMessage_(GadgetID(#Gadget_mtttest_items), #LVM_SUBITEMHITTEST, 0, pInfo)

  If pInfo\iItem <> -1 
  
    ; Debug "Line: " + Str(pInfo\iItem) + "  Cell: " + Str(pInfo\iSubItem)              ; A line and cell has been selected.

    btText.s = GetGadgetItemText(#Gadget_mtttest_items, pInfo\iItem, pInfo\iSubItem)
     
    ChangeToolTip(#Gadget_mtttest_items, btText.s)

  EndIf

EndProcedure

;============================================================================================================================
; Get the number of columns from a LisIconGadget
;============================================================================================================================

Procedure GetColumnCount(Gadget.l)

  hhWnd = SendMessage_(GadgetID(1), #LVM_GETHEADER, 0, 0)
  
  ProcedureReturn SendMessage_(hhWnd, #HDM_GETITEMCOUNT, 0, 0)
  
EndProcedure

;===========================================================================================================================
; Main form handler code
;============================================================================================================================

If Window_mtttest()

  MyBalloonToolTips(#Window_mtttest, #Gadget_mtttest_items, "We are ready to go!")            ; Add a one time tool tip

  AddGadgetItem(#Gadget_mtttest_items, -1, "George Harrison"  + Chr(10) + "The Beatles")      ; Add some junk to our list
  AddGadgetItem(#Gadget_mtttest_items, -1, "Gwen Stefani"     + Chr(10) + "No Doubt")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Andrea Corr"      + Chr(10) + "The Corrs")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Gene Simmons"     + Chr(10) + "Kiss")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Beyonce Knowles"  + Chr(10) + "Destiny's Child")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Glenn Shorrock"   + Chr(10) + "Little River Band")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Amy Lee"          + Chr(10) + "Evanescence")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Steve Tyler"      + Chr(10) + "Aerosmith")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Lene Nystrom"     + Chr(10) + "Aqua")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Deborah Harry"    + Chr(10) + "Blondie")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Shakira"          + Chr(10) + "(Band unknown)")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Pink"             + Chr(10) + "(Band unknown)")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Pat Benatar"      + Chr(10) + "(Band unknown)")
  AddGadgetItem(#Gadget_mtttest_items, -1, "Tina Karol"       + Chr(10) + "(Band unknown)")
  
  program\quit = 0
  
  SetActiveWindow(#Window_mtttest)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Select EventWindow()
          Case #Window_mtttest                    : program\quit = 1
        EndSelect
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Gadget_mtttest_items
            Select EventType()
              Case #PB_EventType_LeftDoubleClick  : TrackListIconPos()
              Case #PB_EventType_RightDoubleClick
              Case #PB_EventType_RightClick
              Default
            EndSelect
        EndSelect
    EndSelect
  Until program\quit
  CloseWindow(#Window_mtttest)
EndIf
End


Posted: Sun Jun 17, 2007 9:34 pm
by utopiomania
But I didn't use your changeTooltip() procedure! Try and run the snippet I posted and tell
me what you see. Is there a balloon tooltip on button 3 & 4 ?

Posted: Mon Jun 18, 2007 2:43 am
by Fangbeast
Yes, there is. With or without the compiler switch.

Posted: Mon Jun 18, 2007 9:04 pm
by utopiomania
Thanks for checking this out! Just found out that 'EnableBalloonTips' in my registry was set to 0, so ballon tooltips
was disabled. Your code works great now :)

Posted: Wed Jun 20, 2007 11:47 pm
by rsts
Was impressed by this when I saw it Sunday.

Then today my partner asked me, 'Can you do something to make those (default windows) tooltips more attractive'?

"Well, now that you mention it, I just might be able to work something up."

Thanks again Fangles. Another very nice addition to the PB toolkit. :)

cheers

THanks

Posted: Thu Jun 21, 2007 2:44 am
by Fangbeast
Just following on others work here.

I also put all the tips into a big procedure with Select/Case statements so that I can load and unload the tooltips at will as some people get annoyed with them after a while.

I might add an option to change colour and store the state in an .ini file as I use those for everything.

You mentioned "partner", as in business partner? (sly grin), any money for my tips?? (VERY EVIL GRIN).

/me falls off the chair laughing and squishes the cat.

Re: THanks

Posted: Thu Jun 21, 2007 4:11 am
by rsts
Fangbeast wrote:Just following on others work here.

I also put all the tips into a big procedure with Select/Case statements so that I can load and unload the tooltips at will as some people get annoyed with them after a while.

I might add an option to change colour and store the state in an .ini file as I use those for everything.

You mentioned "partner", as in business partner? (sly grin), any money for my tips?? (VERY EVIL GRIN).

/me falls off the chair laughing and squishes the cat.
Yes, business partner. He's also my brother. He handles the development and maintenance of the web site and assists with design and testing.

And sure, we'll cut you in for a share of the profit from our freeware :D

cheers

Good reply!!

Posted: Thu Jun 21, 2007 7:31 am
by Fangbeast
I laughed so hard that I swallowed my cat. (Without sauce even!)