Reputation: 11
I am looking for a proper way to close a UI window. The following code works for GMS 1.x.
Class mainUI:uiframe {
void CloseMe(object self){
DocumentWindow win=self.GetFrameWindow();
if(win.WindowIsValid()) win.WindowClose(0);
}
}
But this code crashes DigitalMicrograph consistently under GMS 2.33.
Upvotes: 0
Views: 152
Reputation: 3184
As Mike pointed out in the comment: The answer is to use dlg.Close()
where dlg would be your dialog object.
Here is an example for GMS 3.2. ( See also this for GMS 3.1 )
class myDlg : UIframe
{
void OnClose( object self )
{
self.Close()
}
object InitAndLaunch( object self )
{
TagGroup dlg, dlgItems
dlg = DLGCreateDialog( "test", dlgItems )
dlgItems.DLGAddElement( DLGCreatePushButton( "Close", "OnClose" ) )
self.Init(dlg)
self.Display( "Test" )
return self
}
}
Alloc(myDLG).InitAndLaunch()
Upvotes: 0