Vanishing tooltips on Windows XP

Just starting out? Need help? Post your questions and find answers here.
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Vanishing tooltips on Windows XP

Post by Little John »

Hi all,

when I have some gadgets with tooltips, after clicking at any gadget the tooltip of that gadget is not visible any more (PB 4.61 on Windows XP x86). The following demo code shows the problem:

Code: Select all

;-- Window
Enumeration
   #Win
EndEnumeration

;-- Gadgets
Enumeration
   #CheckBox
   #BtnOpen
   #BtnInfo
EndEnumeration

Define Event.i, file$

OpenWindow(#Win, #PB_Ignore, #PB_Ignore, 130, 70, "Tooltip demo")
CheckBoxGadget(#CheckBox, 10, 10, 70, 20, "Check me")
ButtonGadget(#BtnOpen, 10, 40, 50, 20, "Open")
ButtonGadget(#BtnInfo, 70, 40, 50, 20, "Info")

GadgetToolTip(#CheckBox, "Checkbox tip")
GadgetToolTip(#BtnOpen, "Open tip")
GadgetToolTip(#BtnInfo, "Info tip")

Repeat
   Event = WaitWindowEvent()
   Select Event
      Case #PB_Event_Gadget
         Select EventGadget()
            Case #CheckBox
            Case #BtnOpen
               file$ = OpenFileRequester("", "", "*.*", 0)
            Case #BtnInfo
               MessageRequester("Current time", FormatDate("%hh:%ii", Date()))
         EndSelect
   EndSelect  
Until Event = #PB_Event_CloseWindow
When I move the mouse over the checkbox or its corresponding text, its tooltip appears. But when I then cklick at the checkbox, the tooltip disappears. The same happens with the buttons, for instance the "Info" button: When I cklick at the button, a message box appears. After closing the message box, and moving the mouse curser over the "Info" button again, there is no tooltip. It seems that any event related to a gadget makes the tooltip of that gadget disappear.

It seems that the issue can be fixed, by calling GadgetToolTip() not only during creation of the window, but also each time when there is an event for the respective gadget:

Code: Select all

;-- Window
Enumeration
   #Win
EndEnumeration

;-- Gadgets
Enumeration
   #CheckBox
   #BtnOpen
   #BtnInfo
EndEnumeration

Define Event.i, file$

OpenWindow(#Win, #PB_Ignore, #PB_Ignore, 130, 70, "Tooltip demo")
CheckBoxGadget(#CheckBox, 10, 10, 70, 20, "Check me")
ButtonGadget(#BtnOpen, 10, 40, 50, 20, "Open")
ButtonGadget(#BtnInfo, 70, 40, 50, 20, "Info")

GadgetToolTip(#CheckBox, "Checkbox tip")
GadgetToolTip(#BtnOpen, "Open tip")
GadgetToolTip(#BtnInfo, "Info tip")

Repeat
   Event = WaitWindowEvent()
   Select Event
      Case #PB_Event_Gadget
         Select EventGadget()
            Case #CheckBox
               GadgetToolTip(#CheckBox, "Checkbox tip")     ; <== fix
            Case #BtnOpen
               GadgetToolTip(#BtnOpen, "Open tip")          ; <== fix
               file$ = OpenFileRequester("", "", "*.*", 0)
            Case #BtnInfo
               GadgetToolTip(#BtnInfo, "Info tip")          ; <== fix
               MessageRequester("Current time", FormatDate("%hh:%ii", Date()))
         EndSelect
   EndSelect  
Until Event = #PB_Event_CloseWindow
But I wonder whether this behaviour of the tooltips is intended.

Regards, Little John

//edit 2012-06-17: changed the thread title
Last edited by Little John on Sun Jun 17, 2012 11:09 am, edited 1 time in total.
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: Vanishing tooltips

Post by Arctic Fox »

Hi Little John!

Does the tooltip re-appear when you move the cursor back over e.g. the checkbox again after clicking it?

Here on Windows 7 the tooltip appears upon mouse-over and disappears after clicking the gadget. If I move the cursor away from the gadget and back again, the tooltip re-appears.
With your workaround it re-appears right after clicking the gadget (no need to move the cursor). I think the original behaviour is the intented one, though.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Vanishing tooltips

Post by srod »

I know that there were problems on XP with balloon tips, but was not aware of any problems with standard tips.

Try the following (some old code I have lying around) to see if any of these behave themselves :

Code: Select all

Enumeration 
  #Win 
  #Btn1 
  #Btn2 
  #Btn3 
  #Btn4 
EndEnumeration 

Declare ToolTip(Win, id, style, Icon, Center, Title.s, Tip.s,  FgColor=0, BgColor=0,font=0) 

LoadFont(1, "Times New Roman", 10)

If OpenWindow(0, 0, 0, 300, 300, "Tooltip Styles",#PB_Window_ScreenCentered|#PB_Window_SystemMenu) 

  ButtonGadget(#Btn1, 110, 40, 80, 20, "Button1") 
  ToolTip(#Win, #Btn1, 0, 0, 0, "", "This is a boring old Tooltip") 

  ButtonGadget(#Btn2, 110,100, 80, 20, "Button2") 
  ToolTip(#Win, #Btn2, 0, 1, 1, "Title", "Not that boring old Tooltip", 0, RGB(226, 255, 255),FontID(1)) 

  ButtonGadget(#Btn3, 110, 160, 80, 20, "Button3") 
  ToolTip(#Win, #Btn3, 1, 2, 0, "ss", "This is a multi line Tooltip This is a multi line Tooltip", 0, RGB(226, 255, 255)) 

  ButtonGadget(#Btn4, 110, 220, 80, 20, "Button4") 
  ToolTip(#Win, #Btn4, 1, 3, 0, "This is:", "A centered Tooltip", RGB(57, 120, 63), RGB(226, 255, 255)) 
  Repeat 
  Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 

;Adds a tooltip to Id.  Style: 0 = ordinary, 1 = balloon. Center: 1 = center the stem 
;Icon: 0 = No icon, 1 = Info, 2 = Warn, 3 = Error, (See #TOOLTIP_ constants) 
Procedure ToolTip(Win, id, style, Icon, Center, Title.s, Tip.s,  FgColor=0, BgColor=0,font=0) 
   TT = CreateWindowEx_(0, "Tooltips_Class32", "", #TTS_BALLOON * style, 0, 0, 0, 0, 0, 0, 0, 0) 
  If FgColor 
    SendMessage_(TT, #TTM_SETTIPTEXTCOLOR, FgColor, 0) 
  EndIf 
  If BgColor 
    ;Set the tip background color 
    SendMessage_(TT, #TTM_SETTIPBKCOLOR, BgColor, 0) 
  EndIf 
  If font
    SendMessage_(TT, #WM_SETFONT, font, #True) 
  EndIf 
   ti.TOOLINFO\cbSize = SizeOf(TOOLINFO) 
   ti\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS |  (#TTF_CENTERTIP * Center) 
   ti\uId = GadgetID(id) 
   ti\lpszText = @Tip 
   SendMessage_(TT, #TTM_ADDTOOL, 0, ti) 
   SendMessage_(TT, #TTM_SETMAXTIPWIDTH, 0, 150) 
   SendMessage_(TT, #TTM_SETTITLE, Icon, Title) 
EndProcedure 

I may look like a mule, but I'm not a complete ass.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Vanishing tooltips

Post by IdeasVacuum »

When I move the mouse over the checkbox or its corresponding text, its tooltip appears. But when I then click at the checkbox, the tooltip disappears. The same happens with the buttons, for instance the "Info" button: When I cklick at the button, a message box appears. After closing the message box, and moving the mouse curser over the "Info" button again, there is no tooltip. It seems that any event related to a gadget makes the tooltip of that gadget disappear.
I have always thought it to be normal, though over elaborate, XP behavior with Microsoft thinking that once the User has clicked that button, they know what it is for and the tool tip is redundant. If you recall the very early days on Windows, apps used to give you the option to switch-off tool tips because as a so-called expert User, tool tips were an 'annoyance'. On the other hand, it could just be a plain old XP bug. I say XP rather than PB because I have the same behavior with non PB apps on my machine.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Little John
Addict
Addict
Posts: 4791
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Vanishing tooltips

Post by Little John »

Arctic Fox wrote:Here on Windows 7 the tooltip appears upon mouse-over and disappears after clicking the gadget.
The same here on Windows XP.
Arctic Fox wrote:If I move the cursor away from the gadget and back again, the tooltip re-appears.
Interesting! This does not happen on Windows XP. I have to move the cursor to another gadget with an attached tooltip. Only after another tooltip has been displayed, when I then move the cursor back to the first gadget, then the first tooltip is shown again. So this seems to be a special Windows XP problem.
srod wrote:Try the following (some old code I have lying around) to see if any of these behave themselves
I didn't know that it's possible to create green tooltips etc. Cool! However, the code does not solve my particular problem.
IdeasVacuum wrote:On the other hand, it could just be a plain old XP bug. I say XP rather than PB because I have the same behavior with non PB apps on my machine.
Yes, I think it's an XP bug. IMHO simply moving the cursor away from the gadget and back again, should make the tooltip re-appear (like on Windows 7).

Thanks to all of you for your replies!

Regards, Little John
Post Reply