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

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 7) (EGrid custom control)
Chris Boss
Administrator
posted 04-05-2007 04:27 PM     Click Here to See the Profile for Chris Boss     Edit/Delete Message Reply w/Quote
This "walk through" is about using the EGrid custom control in the Designer.

(Prepare) First, you need to copy the EGrid DLL to the same folder as the Designer. Also you need to copy the appropriate EZC (custom control definition) file for Egrid to the same folder. The EZC file is a text file, which defines the attributes of the custom control, so the designer can use it.

Here is the EZC file for EGrid, which I created. You can modify it to change aspects of it if you need to.

code:



<<<DESC>>>
EGrid Pro
<<<END>>>
<<<CLASS>>>
EGRID32
<<<END>>>
<<<DLL>>>
EGRID32PRO.DLL
<<<END>>>
<<<INCLUDES>>>
#INCLUDE "c:\egrid\EGRID32PRO.INC"
<<<END>>>
' syntax: FunctionName|par1
' par1 must be a string in quotes or a numeric value (long)
<<<REGISTER>>>
REGISTEREGPCLASS|"EGRID32"
<<<END>>>
' Property Character|Style|Style Numeric Value
' or
' Property Character|Style Description|Style|Style Numeric Value
' maximum of 30 styles allowed
' extend styles must have [EX] before value
' Note: %WS_CHILD and %WS_VISIBLE are always assumed so don't define
<<<STYLES>>>
>|Select Headers|%EGS_SELECTHEADERS|&H00000001
-|Show Headers|%EGS_SHOWHEADERS|&H00000002
%|Use Formulas|%EGS_USEFORMULAS|&H00000004
$|Repaint on Scroll|%EGS_REPAINTONSCROLL|&H00000010
?|Virtual Grid|%EGS_VIRTUALGRID|&H00000080
#|Display Grid Lines|%EGS_GRIDLINES|&H00000100
A|Allow Right Button Input|%EGS_ALLOWRIGHTBUTTON|&H00000040
C|Use Font in Cell|%EGS_USEFONTONCONTROL|&H00000200
D|Disabled|%WS_DISABLED|&H8000000
F|Flat Border|%WS_BORDER|&H800000
G|Use Gradient Colors|%EGS_USEGRADIENT|&H00001000
H|Horizontal ScrollBar|%EGS_HSCROLL|&H00100000
I|Invisible Background|%WS_EX_TRANSPARENT|[EX]&H00000020
M|Multi Selection|%EGS_MULTISELECTION|&H00000008
N|Disable (No) Edit|%EGS_DISABLEEDIT|&H00000020
O|Use Overlay for Selection|%EGS_OVERLAYSELECTION|&H00000800
R|Raised Border|%WS_DLGFRAME|&H400000
S|Sunken Border|%WS_EX_CLIENTEDGE|[EX]&H00000200
T|Tabstop|%WS_TABSTOP|&H10000
U|Use Mouse Wheel|%EGS_USEMOUSEWHEEL|&H00000400
V|Vertical ScrollBar|%EGS_VSCROLL|&H00200000
Z|Sizeable Border|%WS_THICKFRAME|&H8000000
<<<END>>>
<<<USECOLORMSG>>>
NO
<<<END>>>
<<<USEFONTMSG>>>
NO
<<<END>>
<<<DEFAULTTEXT>>>
50,100
<<<END>>>
<<<NOTIFY>>>
<<<END>>>
<<<INITCODE>>>
REGISTEREGPCLASS "EGRID32"
<<<END>>>
<<<CODE>>>

<<<END>>>


Now let's use EGrid in the Designer:

(1) Create a Form which we will put the EGrid control on.


(2) In the Project Properties Dailog, set the option "Copy Runtimes with Project" to "3 - All"

This will make the designer copy all the DLL's found in the same folder as the designer to your source code folder. You can set this option to only copy the EZGUI runtimes and then manually copy the EGrid DLL to your apps folder, if you prefer. To begin with it is easier to let the designer just copy all the runtimes (DLL's).

(3) Create a Custom control on your Form. Initially the control will be a blank control (EZGUI temporarily uses a label control).

(4) Double click the control and display its property dialog. Initially it too we be blank (no available properties) and no control class defined.

(5) Select the EGrid control class from the drop down combobox (class field) and then select the properties (styles) you want for the control. EGrid uses the text field for passing initialization data, so you can set it too. I suggest selecting the %EZ_Notify event from the event list, since EGrid uses the WM_NOTIFY message for passing events, and %EZ_Notify is EZGUI's version of this. This will generate a unique subroutine, just for processing the notification events. If you need to initialize the control, it is best to send EGrid messages during the controls %EZ_Loaded event, which occurs immediately after the control is created. The Designer generates a global variable for storing the controls handle, but you can also retrieve it using the EZ_Handle function.


(6) Generate the apps code.


(7) Compile the application.


Here is the source code for this application:


code:



' *************************************************************************************
' Code Generated by EZGUI Visual Designer 4.0
' Portions: Copyright Christopher R. Boss, 2003 to 2006
' All Rights Reserved !
' Registered EZGUI 4.0 users may use this code Royalty Free !
' *************************************************************************************
'
' --------------------------------------------------------
' WARNING ! Do Not Modify any code WITHIN Protected Sections !
' You can add code (Sub,Function,etc.) BEFORE any Protected Routine
' by using the following CODE TAGS: '<<SAVE>> '<<END>>
' and the Designer will not remove it.
' --------------------------------------------------------
'

' ======================================
' [PROTECTED CODE] Do NOT Edit !
' ======================================


'
#COMPILE EXE
#DIM ALL ' This is helpful to prevent errors in coding
' ------------------------------
' Enable all constants below to
' customize maximums in EZGUI
' runtime.
' ------------------------------
' %EZGUI_MaxColors = 800
' %EZGUI_MaxFonts = 800
' %EZGUI_MaxImages = 300
' %EZGUI_MaxControls = 1500
' %EZGUI_MaxForms = 150
' %EZGUI_MaxMenus = 200
' ------------------------------
' --------------------
#INCLUDE "C:\ezgui40pro\includes\ezgui40.inc" ' EZGUI Include file for Declares
' --------------------
#INCLUDE "c:\egrid\EGRID32PRO.INC"
' *************************************************************************************

' *************************************************************************************
' Code Generator Defined Constants and 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_CUSTOM1 = 100

DECLARE SUB FORM1_CUSTOM1_Events(MyID&, CMsg&, CVal&, Cancel&)
DECLARE SUB FORM1_CUSTOM1_Notify(BYVAL CVal&, Cancel&)

' *************************************************************************************
' Code Generator Defined Global Variables and Types
' *************************************************************************************
' --------------------------------
GLOBAL hFORM1_CUSTOM1&
' --------------------------------

' Note: Do NOT change the names of the EZGUI Callback Procedures !

' --------------------
#INCLUDE "C:\ezgui40pro\includes\ezwmain.inc" ' EZGUI Include file for WinMain
' --------------------

' *************************************************************************************
' User Defined Global Variables and Types
' (Put code in CODE TAGS! to protect from deletion by Code Generator !)
' *************************************************************************************

SUB EZ_Main(VerNum&) ' (PROTECTED)
EZ_Reg %EZ_CUSTID,%EZ_REGNUM
EZ_DefImageFolder "Graphics"
REGISTEREGPCLASS "EGRID32"
EZ_AllowCommandEvents 0
EZ_AllowKeyEvents 1
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, 4
EZ_DefSystemColor 33, 5
EZ_DefSystemColor 34, 15
EZ_DefSystemColor 35, 24
EZ_DefColorL 36, &HB96FFF
EZ_DefColorL 37, &H14AB9F
EZ_DefColorL 38, &H47A7FF
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 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 ELSE
END SELECT
END SUB

' -------------------------------------------------------------------------------------

' *************************************************************************************
' Applications FORM Code
' *************************************************************************************


' ======================================
' [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$, "EGrid Demo", 0, 0, 78, 33, "C"
END SUB

SUB EZ_FORM1_Design() ' (PROTECTED)
LOCAL CText$
EZ_Color-1,-1
EZ_UseFont 4
EZ_AllowLoadingEvent 2
hFORM1_CUSTOM1&=EZ_ControlEX("Form1", %FORM1_CUSTOM1, 2.5, 2, 71.5, 29.25, "EGRID32", "50,100", _
%WS_CHILD OR %WS_VISIBLE OR _
%EGS_SELECTHEADERS OR _
%EGS_SHOWHEADERS OR _
%EGS_GRIDLINES OR _
%EGS_USEGRADIENT OR _
%EGS_HSCROLL OR _
%EGS_MULTISELECTION OR _
%EGS_VSCROLL,_
%WS_EX_CLIENTEDGE)
' -----------------------------------------------
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_CUSTOM1
FORM1_CUSTOM1_Events CID&, CMsg&, CVal&, Cancel&
IF CMsg&=%EZ_Notify THEN
FORM1_CUSTOM1_Notify CVal&, Cancel&
END IF
CASE ELSE
FORM1_Events CID&, CMsg&, CVal&, Cancel&
END SELECT
END SUB

' ======================================
' [USER ACCESSABLE CODE] You may Edit !
' ======================================

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 ELSE
END SELECT
CASE ELSE
END SELECT
END SUB

SUB FORM1_CUSTOM1_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Click
CASE ELSE
END SELECT
END SUB

SUB FORM1_CUSTOM1_Notify(BYVAL CVal&, Cancel&)
LOCAL hCtrl&, ID&, NCode&
EZ_GetNotify CVal&, hCtrl&, ID&, NCode&
SELECT CASE NCode& ' Notification Code
CASE ELSE
END SELECT
END SUB


'<<END ALL FORMS>> UnKnown Routines follow:
#IF %EZ_NOSKIPCODE
#ENDIF 'PARSE END



Much of the event code for your EGrid control will be placed in the following subroutine generated by the designer:

code:



SUB FORM1_CUSTOM1_Notify(BYVAL CVal&, Cancel&)
LOCAL hCtrl&, ID&, NCode&
EZ_GetNotify CVal&, hCtrl&, ID&, NCode&
SELECT CASE NCode& ' Notification Code
CASE ELSE
END SELECT
END SUB

This subroutine will be called whenever the WM_NOTIFY message occurs for the control. EZGUI has its own command set for easily accessing this message. The CVal& parameter here is the same thing as the lParam value of the WM_NOTIFY message, so you can use it to set your pointer to the Egrid data structure used for the WM_NOTIFY message. EZGUI can quickly get the notification event by calling the EZ_GetNotify command.

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.