Page 1 of 1
BalloonTip Bug?
Posted: Wed May 16, 2007 2:55 pm
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?
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
;
Posted: Wed May 16, 2007 3:38 pm
by srod
It's an xp themes thing. Try turning off the themes in the compiler options and you shouldn't get this behaviour.
Posted: Wed May 16, 2007 4:22 pm
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.
Posted: Wed May 16, 2007 6:02 pm
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
Posted: Wed May 16, 2007 6:10 pm
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.
Posted: Wed May 16, 2007 6:17 pm
by QuimV
Thanks a lot, netmaestro.
Posted: Sun May 20, 2007 9:19 pm
by QuimV
netmaestro,

Would be possible to include a title and an icon in your workaround ToolTip?
Thanks in advanced!
Posted: Sun May 20, 2007 9:35 pm
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.
Posted: Mon May 21, 2007 6:39 am
by QuimV
You are right.

Thans a lot, netmaestro
Posted: Fri Feb 01, 2008 2:31 pm
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.