And don't generate an error

Therfore UnbindEvent() was needed.
Code: Select all
Procedure CloseAboutWindow()
Protected Win.i
Win = EventWindow()
If GetWindowData(Win)
RemoveWindowTimer(Win, 1)
UnbindEvent(#PB_Event_Timer, @CloseAboutWindow(), Win)
EndIf
UnbindEvent(#PB_Event_DeactivateWindow, @CloseAboutWindow(), Win)
CloseWindow(Win)
EndProcedure
Procedure About(Timeout.i=0)
Protected Win.i
Win = OpenWindow(#PB_Any, 0, 0, 200, 100, "About", #PB_Window_Tool | #PB_Window_WindowCentered, WindowID(GetActiveWindow()))
TextGadget(#PB_Any, 10, 10, 100, 20, "This is a demo")
BindEvent(#PB_Event_DeactivateWindow, @CloseAboutWindow(), Win)
If Timeout
SetWindowData(Win , #True)
AddWindowTimer(Win, 1, Timeout)
BindEvent(#PB_Event_Timer, @CloseAboutWindow(), Win)
EndIf
EndProcedure
Define.i Event
OpenWindow(0, 0, 0, 400, 300, "Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateMenu(0, WindowID(0))
MenuTitle("Help")
MenuItem(1, "About")
About(2000)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
If EventMenu() = 1
About()
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow