Posted: Tue Mar 25, 2003 1:56 am
Restored from previous forum. Originally posted by LJ.
Here is the code Timo posted that does not leak. The only difference is the procedure AddButtonToolTip(Handle,Text$) and the calls to it. The .exe leaks about 4K every 3 clicks of the button. The leak must be in the AddButtonToolTip procedure. Is this an incorrect use of the AddButtonToolTip procedure or is it a leak bug?
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)
EndProcedure
OpenWindow(1, 128, 96, 320, 256, #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")
AddButtonToolTip(ButtonGadget,"Test message.")
LoadFont(0, "Times New Roman", 16)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
Gosub UpdateWindow
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
UpdateWindow:
FreeGadget (0)
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")
AddButtonToolTip(ButtonGadget,"Test message.")
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return
Here is the code Timo posted that does not leak. The only difference is the procedure AddButtonToolTip(Handle,Text$) and the calls to it. The .exe leaks about 4K every 3 clicks of the button. The leak must be in the AddButtonToolTip procedure. Is this an incorrect use of the AddButtonToolTip procedure or is it a leak bug?
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)
EndProcedure
OpenWindow(1, 128, 96, 320, 256, #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")
AddButtonToolTip(ButtonGadget,"Test message.")
LoadFont(0, "Times New Roman", 16)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
Gosub UpdateWindow
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
End
UpdateWindow:
FreeGadget (0)
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")
AddButtonToolTip(ButtonGadget,"Test message.")
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return