UBBFriend: Email This Page to Someone!
  Computer Workshop User Forums
  Beginners Startup Tutorials (Read Only)
  EZGUI 4.0 Pro Designer - Walk Through (part 6) (Rebar)

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   EZGUI 4.0 Pro Designer - Walk Through (part 6) (Rebar)
Chris Boss
Administrator
posted 04-05-2007 03:22 PM     Click Here to See the Profile for Chris Boss     Edit/Delete Message Reply w/Quote
This "walk-through" is how to create a Form which uses a Rebar control.

Rebar controls, in EZGUI, become parents to Forms especially created for use on a rebar. You can then put any controls you like on a Form for a rebar and a rebar can be the parent to multiple forms (called Bands).

(1) Create a Rebar control on a Form.
The Rebar can be positioned anywhere, but if you want the Rebar to autosized to the Form, you will have to select the appropriate property in the controls property dialog (double click the control to display this).

(2) Create a New Form which will be a child form for the previous Rebar control.

(3) Add any controls you want to this Form (we will call it a Rebar Form). In this case, I add a Toolbar control and a ComboBox control.

(Save the Rebar Form with a fitting name)

(4) Generate the code for the application (you have two forms, one with a Rebar control on it and the other which will be a child form for the rebar control).

(5) Edit the code in the Rebar controls %EZ_Loaded event to add the child form (Rebar Form) to the Rebar control. You can add multiple forms to the Rebar controls (called Bands).

(To add the child form to the Rebar control, simply call the subroutine generated by the Designer for the Rebar Form)

The subroutine generated by the Designer for a Rebar Form calls the EZ_AddRBForm command, instead of the EZ_Form command. This command creates an actual EZGUI Form, but it is designed for use on a Rebar control. Here is the code generated by the designer for this routine:

code:



SUB EZ_RBFORM1_Display(BYVAL FormName$, BYVAL RebarID&, BYVAL BText$, BYVAL ImgIndex&, BYVAL HWidth&, BYVAL BGPict$, BYVAL BProp$) ' (PROTECTED)
EZ_Color -1, -1
EZ_AddRBForm FormName$, RebarID&, 60, 3,"RBFORM1", BText$, ImgIndex&, HWidth&, BGPict$, BProp$
END SUB

(See the EZ_AddRBForm command in Help file for more info of the parameters passed to it)

(6) Compile and Run the program.


Here is the source code for this application:

code:



' Portions: Copyright Christopher R. Boss, 2003 to 2006 , All Rights Reserved !
' Registered EZGUI 4.0 users may use this code Royalty Free !

'
' ======================================
' [PROTECTED CODE] Do NOT Edit !
' ======================================
'
#COMPILE EXE
#DIM ALL ' This is helpful to prevent errors in coding
#INCLUDE "C:\ezgui40pro\includes\ezgui40.inc" ' EZGUI Include file for Declares
'
DECLARE FUNCTION Main_Initialize(BYVAL VerNum&) AS LONG
DECLARE SUB EZ_FORM1_Display(BYVAL Parent$)
DECLARE SUB EZ_FORM1_Design()
DECLARE SUB EZ_FORM1_ParseEvents(CID&, CMsg&, CVal&, Cancel&)
DECLARE SUB FORM1_Events(CID&, CMsg&, CVal&, Cancel&)
'
%FORM1_CANVAS1 = 100
%FORM1_REBAR1 = 105
'
DECLARE SUB FORM1_CANVAS1_Draw(BYVAL Mode&)
DECLARE SUB FORM1_REBAR1_Events(MyID&, CMsg&, CVal&, Cancel&)
DECLARE SUB EZ_RBFORM1_Display(BYVAL FormName$, BYVAL RebarID&, BYVAL BText$, BYVAL ImgIndex&, BYVAL HWidth&, BYVAL BGPict$, BYVAL BProp$)
DECLARE SUB EZ_RBFORM1_Design()
DECLARE SUB EZ_RBFORM1_ParseEvents(CID&, CMsg&, CVal&, Cancel&)
DECLARE SUB RBFORM1_Events(CID&, CMsg&, CVal&, Cancel&)
'
%RBFORM1_COMBOBOX1 = 100
%RBFORM1_TOOLBAR1 = 50
'
DECLARE SUB RBFORM1_COMBOBOX1_Events(MyID&, CMsg&, CVal&, Cancel&)
DECLARE SUB RBFORM1_TOOLBAR1_Events(BYVAL TBarID&, MyID&, BYVAL ButtonN&, CMsg&, CVal&, Cancel&)
'
#INCLUDE "C:\ezgui40pro\includes\ezwmain.inc" ' EZGUI Include file for WinMain
'
SUB EZ_Main(VerNum&) ' (PROTECTED)
EZ_Reg %EZ_CUSTID,%EZ_REGNUM
EZ_DefImageFolder "Graphics"
EZ_AllowCommandEvents 0
EZ_LoadImageLib ""
EZ_DefFont 6, "Arial", 10, "V"
EZ_DefFont 7, "Courier New", 10, "F"
EZ_DefFont 8, "Times New Roman", 10, "V"
EZ_DefFont 9, "Modern", 10, "V"
EZ_DefSystemColor 32, 15
EZ_DefSystemColor 33, 5
EZ_DefSystemColor 34, 15
EZ_DefSystemColor 35, 24
EZ_DefColorL 36, &HB96FFF
EZ_DefColorL 37, &H14AB9F
EZ_DefColorL 38, &H1A64FF
EZ_DefColorL 39, &HD2AACF
EZ_DefColorL 40, &H1CD5E3
EZ_DefColorL 41, &HBC8943
EZ_DefColorL 42, &H6C6AB7
EZ_DefColorL 43, &HDD4489
IF Main_Initialize(VerNum&) THEN
EZ_FORM1_Display ""
END IF
END SUB
'
SUB EZ_DesignWindow(FormName$) ' (PROTECTED)
SELECT CASE FormName$
CASE "FORM1"
EZ_FORM1_Design
CASE "RBFORM1"
EZ_RBFORM1_Design
CASE ELSE
END SELECT
END SUB
'
SUB EZ_Events(FormName$, CID&, CMsg&, CVal&, Cancel&) ' (PROTECTED)
SELECT CASE FormName$
CASE "FORM1"
EZ_FORM1_ParseEvents CID&, CMsg&, CVal&, Cancel&
CASE "RBFORM1"
EZ_RBFORM1_ParseEvents CID&, CMsg&, CVal&, Cancel&
CASE ELSE
END SELECT
END SUB
'
' ======================================
' [USER ACCESSABLE CODE] You may Edit !
' ======================================
'
FUNCTION Main_Initialize(BYVAL VerNum&) AS LONG
LOCAL RV&
RV&=1
FUNCTION=RV&
END FUNCTION
'
'<<BEGINFORM>> "FORM1"
'
' ======================================
' [PROTECTED CODE] Do NOT Edit !
' ======================================
'
SUB EZ_FORM1_Display(BYVAL Parent$) ' (PROTECTED)
EZ_Color -1, -1
EZ_Form "FORM1", Parent$, "My First Rebar control", 0, 0, 65, 19, "CZ"
END SUB
'
SUB EZ_FORM1_Design() ' (PROTECTED)
LOCAL CText$
EZ_Color-1,-1
EZ_SetLayer 3
EZ_UseFont 4
EZ_Canvas %FORM1_CANVAS1, 24, 3.25, 43.5, 18, "S"
FORM1_CANVAS1_Draw -1
EZ_Color-1,-1
EZ_SetLayer 0
EZ_UseFont 4
EZ_Rebar %FORM1_REBAR1, 0, 0, 0, 3.75, 0, "^AS["
EZ_DisplayLayer "FORM1", 1, 0 OR %EZ_DECtrls
END SUB
'
SUB EZ_FORM1_ParseEvents(CID&, CMsg&, CVal&, Cancel&) ' (PROTECTED)
SELECT CASE CID&
CASE %EZ_Window
FORM1_Events CID&, CMsg&, CVal&, Cancel&
CASE %FORM1_REBAR1
FORM1_REBAR1_Events CID&, CMsg&, CVal&, Cancel&
CASE ELSE
FORM1_Events CID&, CMsg&, CVal&, Cancel&
END SELECT
END SUB
'
' ======================================
' [USER ACCESSABLE CODE] You may Edit !
' ======================================
'
'<<SAVE>>
SUB ResizeRebar(BYVAL Form$, BYVAL RebarID&)
LOCAL C!, R!, W!, H!, AC!, AR!, AW!, AH!
EZ_GetSize Form$, AW!, AH!, 0
EZ_GetSizeC Form$,RebarID&, C!, R!, W!, H!
EZ_ResizeC Form$,RebarID&, C!, R!, AW!, H!
END SUB
'<<END>>
'
SUB FORM1_Events(CID&, CMsg&, CVal&, Cancel&)
SELECT CASE CID&
CASE %EZ_Window
SELECT CASE CMsg&
CASE %EZ_Loading
CASE %EZ_Loaded
CASE %EZ_Started
CASE %EZ_Close
CASE %EZ_Size
ResizeRebar "Form1", %FORM1_REBAR1
CASE ELSE
END SELECT
CASE ELSE
END SELECT
END SUB
'
SUB FORM1_CANVAS1_Draw(BYVAL Mode&)
LOCAL AFG&, ABG&, AFnt&, CW&, CH&
AFG&=EZ_FG
ABG&=EZ_BG
AFnt&=EZ_Font
IF Mode&=-1 THEN ' Initial Data
CW&=800 ' emulate 8 inches by .01 inch units
CH&=1050 ' emulate 10.5 inches by .01 inch units
EZ_StartDraw "Form1", %FORM1_CANVAS1, CW&, CH&, ""
EZ_EndDraw
END IF
EZ_Color AFG&, ABG&
EZ_UseFont AFnt&
END SUB
'
SUB FORM1_REBAR1_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Click
CASE %EZ_Loaded
' Add the code in the Rebars %EZ_Loaded event to
' add a rebar Form, which will become a new rebar band:
EZ_RBFORM1_Display "Form1", MyID&, "",0,10,"","|>E"
CASE ELSE
END SELECT
END SUB
'
'<<BEGINFORM>> "RBFORM1"
'
' ======================================
' [PROTECTED CODE] Do NOT Edit !
' ======================================
'
SUB EZ_RBFORM1_Display(BYVAL FormName$, BYVAL RebarID&, BYVAL BText$, BYVAL ImgIndex&, BYVAL HWidth&, BYVAL BGPict$, BYVAL BProp$) ' (PROTECTED)
EZ_Color -1, -1
EZ_AddRBForm FormName$, RebarID&, 60, 3,"RBFORM1", BText$, ImgIndex&, HWidth&, BGPict$, BProp$
END SUB
'
SUB EZ_RBFORM1_Design() ' (PROTECTED)
LOCAL CText$
EZ_Color-1,-1
EZ_UseFont 4
EZ_ComboBox %RBFORM1_COMBOBOX1, 38, 1, 18.5, 13.75, "Item 1|Item 2|Item 3|Item 4|Item 5|", "SAVT"
EZ_SelectItem "RBForm1", %RBFORM1_COMBOBOX1, 0
EZ_Color-1,-1
EZ_UseFont 4
STATIC PN1$
IF PN1$ = "" THEN PN1$ = EZ_LoadPicture("%EZMTOOLBAR{S}")
EZ_Toolbar %RBFORM1_TOOLBAR1, PN1$, "BBBB BBB B|0124678H{New|Open|Save|Close|Cut|Copy|Paste|Print}", "FNORT24X24"
END SUB
'
SUB EZ_RBFORM1_ParseEvents(CID&, CMsg&, CVal&, Cancel&) ' (PROTECTED)
SELECT CASE CID&
CASE %EZ_Window
RBFORM1_Events CID&, CMsg&, CVal&, Cancel&
CASE %RBFORM1_COMBOBOX1
RBFORM1_COMBOBOX1_Events CID&, CMsg&, CVal&, Cancel&
CASE %RBFORM1_TOOLBAR1
RBFORM1_TOOLBAR1_Events CID&, CID&, 0, CMsg&, CVal&, Cancel& ' Main Toobar ID
CASE %RBFORM1_TOOLBAR1+1 TO %RBFORM1_TOOLBAR1+8
LOCAL TBNum&
TBNum& = CID&- %RBFORM1_TOOLBAR1
RBFORM1_TOOLBAR1_Events %RBFORM1_TOOLBAR1, CID&, TBNum&, CMsg&, CVal&, Cancel&
CASE ELSE
RBFORM1_Events CID&, CMsg&, CVal&, Cancel&
END SELECT
END SUB
'
' ======================================
' [USER ACCESSABLE CODE] You may Edit !
' ======================================
'
SUB RBFORM1_Events(CID&, CMsg&, CVal&, Cancel&)
SELECT CASE CID&
CASE %EZ_Window
SELECT CASE CMsg&
CASE %EZ_Loading
CASE %EZ_Loaded
CASE %EZ_Started
CASE %EZ_Close
CASE ELSE
END SELECT
CASE ELSE
END SELECT
END SUB
'
SUB RBFORM1_COMBOBOX1_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
CASE ELSE
END SELECT
END SUB
'
SUB RBFORM1_TOOLBAR1_Events( BYVAL TBarID&, MyID&, BYVAL ButtonN&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Click
CASE ELSE
END SELECT
END SUB
'
'<<END ALL FORMS>> UnKnown Routines follow:
#IF %EZ_NOSKIPCODE
'
SUB FORM1_TEXT1_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
CASE ELSE
END SELECT
END SUB
'
SUB FORM1_TEXT2_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
CASE ELSE
END SELECT
END SUB
'
SUB FORM1_TEXT3_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
CASE ELSE
END SELECT
END SUB
'
SUB FORM1_TEXT4_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
CASE ELSE
END SELECT
END SUB
'
SUB FORM1_TAB1_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Change
EZ_DisplayLayer "FORM1", CVal&, 0 OR %EZ_DECtrls
CASE ELSE
END SELECT
END SUB
#ENDIF 'PARSE END
'



Notice I also added the subroutine to the code, which is called from the parent forms %EZ_Size event, which resizes the rebar control when its parent form is resized. You never have to resize the child forms added to the Rebar control (Rebar forms). The rebar takes care of them. You only need to resize the Rebar control itself, if its parent form's size changes.

Here is the resize code:

code:



'<<SAVE>>
SUB ResizeRebar(BYVAL Form$, BYVAL RebarID&)
LOCAL C!, R!, W!, H!, AC!, AR!, AW!, AH!
EZ_GetSize Form$, AW!, AH!, 0
EZ_GetSizeC Form$,RebarID&, C!, R!, W!, H!
EZ_ResizeC Form$,RebarID&, C!, R!, AW!, H!
END SUB
'<<END>>
'
SUB FORM1_Events(CID&, CMsg&, CVal&, Cancel&)
SELECT CASE CID&
CASE %EZ_Window
SELECT CASE CMsg&
CASE %EZ_Loading
CASE %EZ_Loaded
CASE %EZ_Started
CASE %EZ_Close
CASE %EZ_Size
ResizeRebar "Form1", %FORM1_REBAR1
CASE ELSE
END SELECT
CASE ELSE
END SELECT
END SUB


Thats it!

Like noted above, you can have multiple child forms on a Rebar control, which is where it gets fancy. The Rebar handles the positions of these forms for you though and the user can move them.

All times are EST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | Computer Workshop ( EZGUI ) Home Page

Copyright 2000 to 2007 Christopher R. Boss

Powered by: Ultimate Bulletin Board, Version 5.44
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.