Restored from previous forum. Originally posted by ebs.
Berikco,
Magnificent! I like the added little "touch" of the Information icon.
Thanks for your help,
Eric
Memory Leak on ToolTip or Programming Error?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by LJ.
Fred, it didn't work. Here is the new code with your code added:
Global ToolTipControl
Procedure AddButtonToolTip(Handle,Text$)
#TTS_BALLOON = $40
ToolTipControl=CreateWindowEx_(0,"tooltips_class32","",$D0000000|#TTS_BALLOON,0,0,0,0,WindowID(),0,GetModuleHandle_(0),0)
sendMessage_(ToolTipControl,1044,0 ,0) ;ForeColor Tooltip
sendMessage_(ToolTipControl,1043,$58F5D6,0) ;BackColor Tooltip
sendMessage_(ToolTipControl,1048,0,180) ;Maximum Width of tooltip
Button.TOOLINFO\cbSize=84 ; SizeOf( TOOLINFO )
Button\uFlags=$11
Button\hWnd=Handle
Button\uId=Handle
Button\lpszText=@Text$
SendMessage_(ToolTipControl,$0404,0,Button)
ProcedureReturn ToolTipControl ; Return the handle !
EndProcedure
OpenWindow(1, 0, 0, 796, 550, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget, "Background image example")
CreateGadgetList(WindowID())
CreateImage(1, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ImageGadget(1, 0, 0, WindowWidth(), WindowHeight(), UseImage(1))
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
ButtonGadgettwo = ButtonGadget(2, 80, 204, 160, 128, "My Button Two")
ToolTipHandle1 = AddButtonToolTip(ButtonGadget,"Test message for Button 1")
ToolTipHandle2 = AddButtonToolTip(ButtonGadgettwo,"Test message for Button 2")
LoadFont(0, "Times New Roman", 16)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
Gosub UpdateWindow
Case 2
Gosub UpdateWindow
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
UpdateWindow:
DestroyWindow_(ToolTipHandle1)
DestroyWindow_(ToolTipHandle2)
FreeGadget (0):FreeGadget(2)
UseImage(1)
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(64, 32)
DrawText("Test image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
ButtonGadgettwo = ButtonGadget(2, 80, 204, 160, 128, "My Button Two")
AddButtonToolTip(ButtonGadget,"Test message for Button 1")
AddButtonToolTip(ButtonGadgettwo,"Test message for Button 2")
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return
Fred, it didn't work. Here is the new code with your code added:
Global ToolTipControl
Procedure AddButtonToolTip(Handle,Text$)
#TTS_BALLOON = $40
ToolTipControl=CreateWindowEx_(0,"tooltips_class32","",$D0000000|#TTS_BALLOON,0,0,0,0,WindowID(),0,GetModuleHandle_(0),0)
sendMessage_(ToolTipControl,1044,0 ,0) ;ForeColor Tooltip
sendMessage_(ToolTipControl,1043,$58F5D6,0) ;BackColor Tooltip
sendMessage_(ToolTipControl,1048,0,180) ;Maximum Width of tooltip
Button.TOOLINFO\cbSize=84 ; SizeOf( TOOLINFO )
Button\uFlags=$11
Button\hWnd=Handle
Button\uId=Handle
Button\lpszText=@Text$
SendMessage_(ToolTipControl,$0404,0,Button)
ProcedureReturn ToolTipControl ; Return the handle !
EndProcedure
OpenWindow(1, 0, 0, 796, 550, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget, "Background image example")
CreateGadgetList(WindowID())
CreateImage(1, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ImageGadget(1, 0, 0, WindowWidth(), WindowHeight(), UseImage(1))
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
ButtonGadgettwo = ButtonGadget(2, 80, 204, 160, 128, "My Button Two")
ToolTipHandle1 = AddButtonToolTip(ButtonGadget,"Test message for Button 1")
ToolTipHandle2 = AddButtonToolTip(ButtonGadgettwo,"Test message for Button 2")
LoadFont(0, "Times New Roman", 16)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
Gosub UpdateWindow
Case 2
Gosub UpdateWindow
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
UpdateWindow:
DestroyWindow_(ToolTipHandle1)
DestroyWindow_(ToolTipHandle2)
FreeGadget (0):FreeGadget(2)
UseImage(1)
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(64, 32)
DrawText("Test image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
ButtonGadgettwo = ButtonGadget(2, 80, 204, 160, 128, "My Button Two")
AddButtonToolTip(ButtonGadget,"Test message for Button 1")
AddButtonToolTip(ButtonGadgettwo,"Test message for Button 2")
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm