Callback Procedure Syntax:
            
            Sub EZ_Main ( VerNum& )        (see:   Program Flow Chart  )

              Every Windows program has one common event. This is where Windows makes its first call into a program to run it. In an EZGUI application this "request" to start your program will be marshalled to the EZ_Main callback procedure. This is where your program "always" starts. You must define your first Window (Form) in the EZ_Main procedure, to start your program.

            The VerNum& parameter is a value passed to your program which tells you what version of the EZGUI runtime your application is using. If the value passed was 400 then this would mean that the version of the runtime is 4.00 . If the value passed was 401 then this would mean that the version of the runtime is 4.01 .

Let's look at EZ_Main a little closer :

SUB EZ_Main(VerNum&)     ' (PROTECTED)
     EZ_Reg %EZ_USER,%EZ_REGNUM
     EZ_DefImageFolder "Graphics"
     EZ_AllowCommandEvents  0
     EZ_DefFont 6, "Arial", 12, "L+V"
     EZ_DefFont 7, "Arial", 12, "BV"
     EZ_DefFont 8, "Arial", 14, "L+V"
     EZ_DefFont 9, "Courier New", 12, "BF"
     EZ_DefSystemColor 32, 15
     EZ_DefSystemColor 33, 18
     EZ_DefSystemColor 34, 21
     EZ_DefSystemColor 35, 22
     EZ_DefColorL 36, &HFF
     EZ_DefColorL 37, &H8000
     EZ_DefColorL 38, &H8000FF
     EZ_DefColorL 39, &H4080FF
     EZ_DefColorL 40, &H80FF80
     EZ_DefColorL 41, &HFFFF80
     EZ_DefColorL 42, &HB56AFF
     EZ_DefColorL 43, &HC0C0C0
     IF Main_Initialize(VerNum&) THEN
          EZ_Form1_Display ""
     END IF
END SUB

      The purpose of EZ_Main is not only to have a starting place for your program, but it also is where you would define many starting parameters of your program, such as defining colors and fonts. The code in EZ_Main can not be modified if you are using the Visual Designer using the "Smart Parser" mode. It is considered a protected subroutine. If you want to add your own initialization code, then it should be added to the Main_Initialize subroutine which is called by EZ_Main. The code for this looks like this:

FUNCTION Main_Initialize(BYVAL VerNum&) AS LONG
     LOCAL RV&
     RV&=1
     FUNCTION=RV&
END FUNCTION

      This function is where you would put all of your own customized initialization code for your application. If the function returns a zero, then no form is displayed and the app should terminate immediately.

      EZ_Main will call the procedure which displays the startup form (defined in the Designer).

      Once EZ_Main finishes execution, EZGUI is now in control of your application. In technical terms, EZGUI is running its internal Message Loop, waiting for an event. None of the code in your application will be executed until an Event occurs. An Event is things like a mouse click or movement, a key being pressed, a timer event occurring or a Form requesting to be designed (controls added), etc.

      You will notice that EZ_Main calls a procedure to display the startup (first) Form in your application. In this case the procedure is:

SUB EZ_Form1_Display(BYVAL Parent$)     ' (PROTECTED)
     LOCAL hMainMenu&
     ' Main Menu handle automatically
     ' stored by EZGUI
     hMainMenu&=EZ_DefMainMenu( %FORM1_FILE, "&Files", "")
     EZ_Color -1, -1
     EZ_Form "FORM1", Parent$, "Your Dialog", 0, 0, 50, 18, "C"
END SUB

      This routine is where the Form is actual created (just an empty form with the first main menu entry are created here). The EZ_Form command defines the form and immediately creates it. Before the EZ_Form command finishes, the EZ_DesignWindow procedure will be called for that Form and the forms design code will be executed.

      Again notice this procedure is protected ! This means that only the Visual Designer should modify this procedure (when using the Smart Parser).