You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Chris/Elias:
Do you guys have a demo of creating a EGRID32 grid using EZGUI and printing it? I'm using third-party software to do these things and would
like to use all PowerBASIC.
It appears the EGrid Print Engine handles all the printing for you, so you would use basically the same code use would use for FireFly or any other SDK style coding. About the only difference is that you can use the EZ_SendMessage command instead of the SendMessage API function.
This would require that you have the Egrid Print engine which is a separate product from what I gather.
Another technique, if your Grid only stores text, you can read the grid row by row and then use the EZGUI Print engine to print out your grid. This would allow you to incorporate other stuff besides the grid into your documents.
The creating part is easy in EZGUI. You can even visually work with the grid control in the designer.
Here is some sample code:
Code:
' [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
' --------------------
#INCLUDE "c:\egrid\EGRID32PRO.INC"
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_EGRIDCTRL = 100
%FORM1_LABEL1 = 105
DECLARE SUB FORM1_EGRIDCTRL_Events(MyID&, CMsg&, CVal&, Cancel&)
DECLARE SUB FORM1_EGRIDCTRL_Notify(BYVAL CVal&, Cancel&)
' *************************************************************************************
' Code Generator Defined Global Variables and Types
' *************************************************************************************
' --------------------------------
GLOBAL hFORM1_EGRIDCTRL&
' --------------------------------
' --------------------
#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"
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
' -------------------------------------------------------------------------------------
' ======================================
' [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, 144, 41, "C"
END SUB
'
SUB EZ_FORM1_Design() ' (PROTECTED)
LOCAL CText$
EZ_Color-1,-1
EZ_UseFont 4
EZ_AllowLoadingEvent 2
hFORM1_EGRIDCTRL&=EZ_ControlEX("Form1", %FORM1_EGRIDCTRL, 5.5, 9.25, 132.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)
' -----------------------------------------------
EZ_Color-1,-1
EZ_UseIFont "Tahoma", 20,"BV"
EZ_Label %FORM1_LABEL1, 45, 4.75, 49, 3.25, "EGrid", "C"
' -----------------------------------------------
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_EGRIDCTRL
FORM1_EGRIDCTRL_Events CID&, CMsg&, CVal&, Cancel&
IF CMsg&=%EZ_Notify THEN
FORM1_EGRIDCTRL_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_EGRIDCTRL_Events( MyID&, CMsg&, CVal&, Cancel&)
SELECT CASE CMsg&
CASE %EZ_Click
CASE ELSE
END SELECT
END SUB
'
SUB FORM1_EGRIDCTRL_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
Once you create the grid and load what you want in it, you can call the printing
task in two different ways, #1 is to call the print dialog and define printing settings
manually:
Code:
'Print Using the Printing dialog for confirming configuration.
CALL EGP_PrintDialog(CB.HNDL, HGrid, "Page 1", "Printing Test", "")
Or you can programatically define the printing preferences and
execute the code like this:
Code:
' Print manually, no dialog.
LOCAL HDocument AS LONG
LOCAL PrintFlags AS LONG
' Select what you want to print.
' Note: You can read the last configuration saved by Default dialog
' reading the registry values at: HKEY_CURRENT_USER\Software\SweetHeartGames\PrintEngine
PrintFlags = %EGP_HORZGRIDLINES OR %EGP_VERTGRIDLINES OR %EGP_HORZMARGINLINES OR %EGP_VERTMARGINLINES OR _
%EGP_PRINTBACKGROUND OR %EGP_BACKGROUNDCOLOR OR %EGP_PRINTCONTROLS OR %EGP_TEXT OR %EGP_PRINTBITMAPS
' Make Sure a printer is installed
IF ISFALSE(LEN(EGP_GetDefaultPrinter())) THEN
MSGBOX " No printers are installed.", %MB_ICONERROR OR %MB_OK, "Unable to print"
EXIT FUNCTION
END IF
' Create Document.
HDocument = EGP_CreateDocument(CBHNDL, EGP_GetDefaultPrinter(), "Egrid32 Printing example - Page 1", "", %EGP_PRINT OR %EGP_PORTRAIT) ' You can also use %EGP_LANDSCAPE
' Create a page.
Result = EGP_CreatePage(HDocument, "Page #1")
'Print Egrid32's page 1 in current Printing Page.
EGP_PrintGrid(HDocument, HGrid, 1, 1, PrintFlags, "")
' Finish Page, Document, and print it.
EGP_PrintAndClose(HDocument, "")
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment