BalloonTip Bug?

Just starting out? Need help? Post your questions and find answers here.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

BalloonTip Bug?

Post by QuimV »

:) Hi,

Anybody knows why, in the PureBasic Visual Designer, this code runs fine but in the PureBasic Editor, the BallonTip is shown for about 5 seconds and then don't show anymore? :o

Any idea?

Thanks ind advanced!

Code: Select all

; PureBasic Visual Designer v3.95 build 1485 (PB4Code)

;- Window Constants
;
Enumeration
  #W_0
EndEnumeration

;- Gadget Constants
;
Enumeration
  #Btn_0
EndEnumeration


Procedure BalloonTip(WindowID, Gadget, Text$ , Title$, Icon)
  
  ToolTip=CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON,0,0,0,0,WindowID,0,GetModuleHandle_(0),0)
  SendMessage_(ToolTip,#TTM_SETTIPTEXTCOLOR,GetSysColor_(#COLOR_INFOTEXT),0)
  SendMessage_(ToolTip,#TTM_SETTIPBKCOLOR,GetSysColor_(#COLOR_INFOBK),0)
  SendMessage_(ToolTip,#TTM_SETMAXTIPWIDTH,0,180)
  Balloon.TOOLINFO\cbSize=SizeOf(TOOLINFO)
  Balloon\uFlags=#TTF_IDISHWND | #TTF_SUBCLASS
  Balloon\hWnd=GadgetID(Gadget)
  Balloon\uId=GadgetID(Gadget)
  Balloon\lpszText=@Text$
  SendMessage_(ToolTip, #TTM_ADDTOOL, 0, Balloon)
  If Title$ > ""
    SendMessage_(ToolTip, #TTM_SETTITLE, Icon, @Title$)
  EndIf
  
EndProcedure

Procedure Open_W_0()
  If OpenWindow(#W_0, 216, 0, 600, 300, "New window ( 0 )",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#W_0))
      ButtonGadget(#Btn_0, 70, 40, 110, 80, "")
      BalloonTip(GadgetID(#Btn_0), #Btn_0, "Testing", "Information", #TOOLTIP_INFO_ICON)
      
    EndIf
  EndIf
EndProcedure


Open_W_0()

Repeat ; Start of the event loop
  
  Event = WaitWindowEvent() ; This line waits until an event is received from Windows
  
  WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
  
  GadgetID = EventGadget() ; Is it a gadget event?
  
  EventType = EventType() ; The event type
  
  ;You can place code here, and use the result as parameters for the procedures
  
  If Event = #PB_Event_Gadget
    
    If GadgetID = #Btn_0
      
    EndIf
    
  EndIf
  
Until Event = #PB_Event_CloseWindow ; End of the event loop

End
;
QuimV
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

It's an xp themes thing. Try turning off the themes in the compiler options and you shouldn't get this behaviour.
I may look like a mule, but I'm not a complete ass.
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

You are right, srod.

I turned off the themes in the compiler and now app works fine, but .... the look of the application has changed too and it appears very poor. I need a solution in order to keep the app aspect with XP themes activated an correct the behaviour of the BallonTip.

Have you any idea?

Thanks a lot in advanced.
QuimV
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Code: Select all

; Yet another stupid workaraound by netmaestro 
; 
; Because there are just never enough stupid workarounds 
; 
Global TT, TTI.TOOLINFO 

Procedure ThemesEnabled()
  dlv.DLLVERSIONINFO
  dlv\cbsize=SizeOf(DLLVERSIONINFO) 
  lib=OpenLibrary(#PB_Any,"comctl32.dll") 
  If lib 
    CallFunction(lib,"DllGetVersion",@dlv) 
    DLLVersion = dlv\dwMajorVersion 
    CloseLibrary(lib) 
  EndIf 
  If DLLVersion = 6
    ProcedureReturn 1
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure CreateToolTip(win,gadget,txt) 
  TT=CreateWindowEx_(0,"ToolTips_Class32","",#WS_POPUP | #TTS_NOPREFIX | #TTS_BALLOON,0,0,0,0,WindowID,0,GetModuleHandle_(0),0) 
  SetWindowPos_(TT,#HWND_TOPMOST,0, 0, 0, 0, #SWP_NOMOVE|#SWP_NOSIZE|#SWP_NOACTIVATE) 
  TTI.TOOLINFO 
  TTI\cbSize = SizeOf(TOOLINFO) 
  TTI\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS  
  TTI\hWnd = win 
  TTI\uId = gadget 
  TTI\lpszText = txt 
  SendMessage_(TT, #TTM_ADDTOOL, 0, @TTI) 
EndProcedure 

Procedure CallBack(hwnd, msg, wparam, lparam) 
  result = #PB_ProcessPureBasicEvents 
  ; 
  ; Begin tooltip bug workaround 
  ; 
  If ThemesEnabled()
    If msg = #WM_NOTIFY And wparam = 0 ; 0 = #gadget, change it for a different #gadget
      *status.NMBCHOTITEM = lparam 
      Select *status\dwFlags 
        Case 17 ; #HICF_ENTERING 
          SendMessage_(TT, #TTM_DELTOOL, 0, @TTI) 
          SendMessage_(TT, #TTM_ADDTOOL, 0, @TTI) 
      EndSelect 
    EndIf 
  EndIf 
  ; 
  ; End tooltip bug workaround 
  ; 
  ProcedureReturn result 
EndProcedure 

OpenWindow(0,0,0,222,200,"ButtonGadgets",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
CreateGadgetList(WindowID(0)) 
ButtonGadget(0, 10, 10, 200, 20, "TOOLTIP!") 
ButtonGadget(1, 10, 40, 200, 20, "NO TOOLTIP!", #PB_Button_Left) 
SetWindowCallback(@CallBack()) 
CreateToolTip(WindowID(0),GadgetID(0), @"Hello, I'm a workaround tooltip!") 
    
Repeat : Until WaitWindowEvent()=#WM_CLOSE 
Last edited by netmaestro on Wed May 16, 2007 6:15 pm, edited 1 time in total.
BERESHEIT
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I just realized there is a bit of overkill in this workaround as the HCIF_ENTERING notification is only sent if themes are enabled, meaning the ThemesEnabled test is redundant. You should be safe in removing it.
BERESHEIT
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

Thanks a lot, netmaestro.
QuimV
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

netmaestro,

:) Would be possible to include a title and an icon in your workaround ToolTip?

Thanks in advanced!
QuimV
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Code: Select all

Select *status\dwFlags 
  Case 17 ; #HICF_ENTERING 
    SendMessage_(TT, #TTM_DELTOOL, 0, @TTI) 
    SendMessage_(TT, #TTM_ADDTOOL, 0, @TTI) 
    SendMessage_(TT, #TTM_SETTITLE, LoadIcon_(0, #IDI_ASTERISK), @"  ToolTip Title") ; << Add this line
EndSelect 
You'd wonder why they wouldn't have made elements in the TOOLINFO structure for icon and title, wouldn't you? Looks like a classic case of hanging a bag on the side of something that already exists instead of reworking it properly. That's MS for you. Code by committee.
BERESHEIT
QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

You are right.
:) Thans a lot, netmaestro
QuimV
Seldon
Enthusiast
Enthusiast
Posts: 405
Joined: Fri Aug 22, 2003 7:12 am
Location: Italia

Post by Seldon »

I've tried both versions on Windows Vista (with or without XP themes activated) and the tooltip is shown for just 5 seconds, then it hides and you need to move the mouse over the button again to make it show again.
Post Reply