[Gambas-user] How to do a "confirm" window?
Kchula-Rrit
kchularrit at ...734...
Thu Oct 6 03:50:48 CEST 2005
I've been trying to put together a "confirm" window for program exit and just
cannot get the thing to work. It's just one window with two buttons marked
"Exit" and "Cancel". When I select "Exit" I want to create a new "confirm"
window to see if the user really wants to exit. I've tried everything I can
think of and it's driving me nuts!
Any help appreciated, apologies for length.
Here is the main Class file "FMain.class"
FMain.form is just a window with two buttons, "Exit" and "Cancel".
' Gambas class file
STATIC PUBLIC ExitFlag AS Boolean ' TRUE = Exit, FALSE = Don't Exit
STATIC PUBLIC SUB _init()
ExitFlag = FALSE
END
STATIC PUBLIC SUB _exit()
END
PUBLIC SUB _new()
END
PUBLIC SUB _free()
END
STATIC PUBLIC FUNCTION Run() AS Boolean
DIM hForm AS Form
hForm = NEW FMain
' CExit.Visible = FALSE
' CExit.InExitScreen = FALSE
RETURN hForm.ShowModal()
END
PUBLIC SUB btnExit_Click()
ME.Minimized = TRUE
FExit.InExitScreen = TRUE
FExit.Confirm()
WHILE FExit.InExitScreen = TRUE
' Do Nothing
WEND
IF ExitFlag <> FALSE THEN
ME.Close
ENDIF
' CExit.Delete
' CExit.InExitScreen = FALSE
ME.Minimized = FALSE
ME.Refresh
END
PUBLIC SUB btnCancel_Click()
ME.Close()
END
"End of FMain.class
Here is the FExit.class file:
' This should open a window with two buttons, "Yes" and "No". "Yes" sets an
exit flag in FMain.class, while selecting either closes the confirm' window.
' Gambas class file
PUBLIC InExitScreen AS Boolean
PUBLIC SUB Confirm()
DIM hExitScreen AS FExit
' DIM btnYes AS Button
' DIM btnNo AS Button
hExitScreen = NEW FExit
FMain.ExitFlag = FALSE
' hExitScreen.SetFocus
hExitScreen.Show
hExitScreen.SetFocus
' hExitScreen.Enabled = TRUE
' hExitScreen.Width = 200
' hExitScreen.Refresh
' hExitScreen.Height = 100
hExitScreen.Refresh
' btnYes = NEW btnYes
btnYes.Show
btnYes.Refresh
' btnYes.x = 8
' btnYes.y = 8
' btnYes.Text = "Yes"
' btnYes.Refresh
hExitScreen.Refresh
' btnNo = NEW button(hExitScreen) AS "btnNo"
' btnNo.x = 108
' btnNo.y = 8
' btnNo.Text = "No"
btnNo.Show
btnNo.Refresh
' hExitScreen.Refresh
' hExitScreen.Show
hExitScreen.Refresh
WHILE FExit.InExitScreen = TRUE
' Do Nothing
WEND
END
PUBLIC SUB btnYes_Click()
InExitScreen = FALSE
FMain.ExitFlag = TRUE
END
PUBLIC SUB btnNo_Click()
InExitScreen = FALSE
END
' End of FExit.class
More information about the User
mailing list