However, if the dialog is closed via the button, there is no crash.
Code: Select all
EnableExplicit
Global Quit, XML$, xml
Runtime Enumeration
#Window
#Dialog
#DialogButton
EndEnumeration
Procedure OnWindowClosed()
Quit = 1
EndProcedure
Procedure OnDialogClosed()
FreeDialog(#Dialog)
SetActiveWindow(#Window)
EndProcedure
Procedure OnDialogButtonClicked()
PostEvent(#PB_Event_CloseWindow, DialogWindow(#Dialog), 0)
EndProcedure
XML$ = "<window id='#Dialog' name='TestDialog' text='test' minwidth='250' minheight='200' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu'>"
XML$ + " <vbox>"
XML$ + " <button id='#DialogButton' text='OK' width='90' height='25'/>"
XML$ + " </vbox>"
XML$ + "</window>"
If OpenWindow(#Window, 0, 0, 320, 240, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
xml = ParseXML(#PB_Any, XML$)
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, xml, "TestDialog", 0, 0, 0, 0, WindowID(#Window))
BindEvent(#PB_Event_CloseWindow, @OnWindowClosed(), #Window)
BindEvent(#PB_Event_CloseWindow, @OnDialogClosed(), DialogWindow(#Dialog))
BindGadgetEvent(#DialogButton, @OnDialogButtonClicked())
Repeat : WaitWindowEvent() : Until Quit = 1
Else
Debug DialogError(#Dialog)
EndIf
EndIf