On Fri, 2009-10-16 at 17:44 -0700, bbb888 wrote:
> I can get an exit code from a form shown with rtn = fm.ShowDialog() correctly
> if the user uses an in-form exit such as a exit button :
>
>
> PUBLIC SUB btExit_Click()
>
> ME.Close(60)
>
> END
>
>
>
> But if the user clicks on the [X] in the titlebar all I get is 0 in rtn.
>
>
> Is there a way to trap the exit in the form?
Create a new project.
Add Button1 to FMain.
Create a new form called Form1 <--- Check "Dialog box management" when
you create it. That will create the support code you need next time you
need this feature.
Replace the code in the forms as described below.
You will get 50 returned into nR if the cancel button is pressed, 150 if
OK is pressed, and 100 if the closebox is clicked.
' ***********************************************
' Paste this into FMain, replace what's there
' ***********************************************
' Gambas class file
PUBLIC SUB _new()
END
PUBLIC SUB Form_Open()
END
PUBLIC SUB Button1_Click()
DIM nR AS Integer
DIM f AS NEW Form1
nR = f.Run()
DEBUG nR
END
' ***********************************************
' Paste this into Form1, replace what's there
' ***********************************************
' Gambas class file
PRIVATE SomeValue AS Integer
PUBLIC SUB Run() AS Integer
ME.ShowModal
RETURN SomeValue
END
PUBLIC SUB btnOK_Click()
SomeValue = 150
ME.Close
END
PUBLIC SUB btnCancel_Click()
SomeValue = 50
ME.Close
END
PUBLIC SUB Form_Open()
END
PUBLIC SUB Form_Close()
IF SomeValue = 0 THEN
SomeValue = 100
ENDIF
END
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user