Powerbasic Museum 2020-B

General Category => General Discussion => Topic started by: Robert Sarrazin on August 29, 2011, 11:47:27 PM

Title: Simulated X window bar.
Post by: Robert Sarrazin on August 29, 2011, 11:47:27 PM
Hi, I try to use a bitmap skin and I created ( X ) ???
a button call Xbutton to exit the program.

-----------------------
SUB FORM1_XBUTTON_Events( MyID&, CMsg&, CVal&, Cancel&)
     SELECT CASE CMsg&
          CASE %EZ_Click
                 (what is the best to exit  ::) )
          CASE ELSE
     END SELECT
END SUB
-----------------------
do I have to sent message terminate,
or exit,
or use %WM_CLOSE,0,0   EXIT FUNCTION
or use the END statement (NEW!)  Purpose
Terminate program immediately.
Syntax  END [nErrorLevel&]

I just try to find  the best way to exit :)
Title: Re: Simulated X window bar.
Post by: Christopher Boss on August 30, 2011, 01:12:45 AM
Robert,

Your code is EZGUI event code, not API code, so when using EZGUI you close a form like this:

EZ_UnloadForm "MyFormName"

EZGUI handles the rest. You can put such code in the %EZ_Click event for a button control if you like.

Title: Re: Simulated X window bar.
Post by: Christopher Boss on August 30, 2011, 01:15:21 AM
You can use something like this:


SUB FORM1_XBUTTON_Events( MyID&, CMsg&, CVal&, Cancel&)
     SELECT CASE CMsg&
          CASE %EZ_Click
               EZ_UnloadForm "{ME}"
          CASE ELSE
     END SELECT
END SUB


EZGUI 5.0 supports a new quick syntax, if the code will effect the same form as the event occurred for, which is "{ME}"

Assuming the button control is on the same form you want to close, then "{ME}" is fine.

As far as terminating the application, EZGUI automatically terminates the app when the last form is closed (or unloaded).