• Welcome to PlanetSquires Forums.
 

Quick Tutorial on how to Setup EGrid and EGrid Forms with FFly

Started by Andrew Lindsay, June 21, 2009, 10:26:31 AM

Previous topic - Next topic

Andrew Lindsay

Paul / Elias,

I have just set up my laptop with my PB stuff again and I want to get EGrid working with FireFly.  A couple of questions, how do I get the latest version of the control definition file, and how do I use the form designer with FireFly?

Any assistance would be appreciated.

Regards

Andrew

Elias Montoya

Hello Andrew.

To get the newest Egrid32's definition file for Firefly, you can
visit www.Egrid32.com then go to Upgrade, Enter your registration
email and name, and instead of entering a serial number, enter: EXTRAS

If you have any problems downloading, let me know and i will send
manually.

In the Firefly File, there is a README file with further easy instructions.

:)

Elias Montoya

 Firefly doesnt support the Egrid32 form designer visually, but is easy
to use it as well.

Simply create your forms in the Egrid32 Form designer, save the
form to file and add the file as a resource in your project. Like this:

MY_FORM_NAME   RCDATA DISCARDABLE "C:\MY_FORM_NAME.CGF"

From there, you can load your form in an Egrid32 in firefly with one
single line:

EG32_LOADFORM(Hgrid, "MY_FORM_NAME", 0)

This function is in the EG32FORMS.INC module.

Note that this is a high level funtion which simply loads the form into Egrid32.
If you want more loading options you can take a look at %EG_SETDATASTREAM,
this command allows you to load some sections and some not. For example
load all text data and dont load appearance, or dont load zoom, etc.

There is an example for this in the Egrid32 DEMO file downloadable from
www.Egrid32.com

If you dont want to embed your forms into Firefly, you can load them from
file as well. See Example in next reply. :)

Elias Montoya


The following two functions allow you to save and load Egrid32's contents to file
programatically, giving you possibilities to, not only use the form designer while
you design your appliucations, but also allow end user to design their own forms.

I wish more people knew about this, i would get thousands of customers. :)

'==============================================================================================================================
FUNCTION Egrid32_SaveToFile(Hgrid AS LONG, FileName AS STRING) AS LONG
   IF SendMessage(Hgrid, %EG_ISVALIDEGRIDHANDLE, 0, 0) <> 123456 THEN EXIT FUNCTION
   LOCAL FormAsText AS STRING
   LOCAL Hmem AS LONG
   LOCAL FF AS LONG
   HMem = SendMessage(Hgrid, %EG_GETDATASTREAM, 0, 0)
   IF ISFALSE(Hmem) THEN EXIT FUNCTION
   FormAsText = PEEK$(Hmem, GlobalSize(Hmem))
   FF = FREEFILE
   ERRCLEAR
   OPEN FileName FOR BINARY AS #FF
    IF ERR THEN EXIT FUNCTION
    PUT #FF,,FormAsText
   CLOSE #FF
   GlobalFree(HMem)
   FUNCTION = %TRUE

END FUNCTION
'==============================================================================================================================
FUNCTION Egrid32_LoadFromFile(Hgrid AS LONG, FileName AS STRING) AS LONG
   IF SendMessage(Hgrid, %EG_ISVALIDEGRIDHANDLE, 0, 0) <> 123456 THEN EXIT FUNCTION
   LOCAL FormAsText AS STRING
   LOCAL Hmem AS LONG
   LOCAL FF AS LONG
   FF = FREEFILE
   ERRCLEAR
   OPEN FileName FOR BINARY ACCESS READ AS #FF
    IF ERR THEN EXIT FUNCTION
    FormAsText = SPACE$(LOF(FF))
    GET #FF,,FormAsText
   CLOSE #FF
   Hmem = GlobalAlloc(%GMEM_FIXED OR %GMEM_ZEROINIT, LEN(FormAsText))
   IF Hmem THEN
    POKE$ Hmem, FormAsText
    SendMessage(Hgrid, %EG_SETDATASTREAM, HMem, %EG_APPLYPROPERTIES OR %EG_RESTORESELECTION OR %EG_RESTOREPOSITION)
    GlobalFree(HMem)
    HMem = 0
    FUNCTION = %TRUE
   END IF
END FUNCTION
'==============================================================================================================================   

Andrew Lindsay

Elias,

Thanks for the prompt responses.  One other quick question, does the above method allow saving data from a grid?  i.e. if I enter lots of data into the grid, can I then use the above method to save everything and then load it again at a later date?

Also, is there an easy way to load and save CSV files, or to handle tab or CVS data to be parsed directly into the grid from a clipboard?

Regards

Andrew

Elias Montoya

Hello Andrew,

Yes. You can use the above function to save to file and load at a later time. It uses a propietary format, as it saves images, icons and every detail of the grid in the binary file.

Egrid32 doesn't have a native function to save/load to CSV, If what you need is a plain text or CSV method for saving the contents of the grid, there should be no problem coding it.

Let me dig into my codes and see if i can find something that fits your needs.




Andrew Lindsay

Elias,

Thanks for your help.  I have added an EGRID control to a form, and added a CGF file to the resource, but when I try to compile I get the following error...

PowerBASIC for Windows
PB/Win  Version 9.00
Copyright (c) 1996-2008 PowerBasic Inc.
Venice, Florida USA
All Rights Reserved

Error 519 in H:\PB\TOOLS\FIREFLY VISUAL DESIGNER\PROJECTS\WOW\SOURCE\CODEGEN_PROJECT1_FORM1_FORM.INC(656:001):  Missing declaration: EG32_LOADFORM
Line 656: EG32_LOADFORM(HWND_FORM1_EGRID321, "WOW_GRID", 0)



It is as if the INC file is not being loaded.  Where do I load the inc file?  I appear to have added the control correctly as it shows on the tool bar etc.

Any ideas would be appreciated.

Regards

Andrew

TechSupport

I haven't tried it but maybe try adding the INC file to the FireFly project as a "Module".


Andrew Lindsay

OK, a few small baby steps are being made at the moment.

Firstly, I have had to add the Include file as a module.  Easy enough. However, adding the include file was insufficient to get the program to compile, I then had to copy the TYPE declarations from the Include File (EG32FORMS.INC) to the {General|Other} section of FireFly - a little bit strange perhaps?

Now when I make Elias' suggestions to load in the preformatted form using

QuoteCode: MY_FORM_NAME   RCDATA DISCARDABLE "C:\MY_FORM_NAME.CGF"
From there, you can load your form in an Egrid32 in firefly with one
single line:

EG32_LOADFORM(Hgrid, "MY_FORM_NAME", 0)
This function is in the EG32FORMS.INC module.

Now I am getting an error that states :
QuoteThe Egrid32's form designer received as input a non compilable form.
Please make sure the form file was generated with the Egrid32's form designer, and that the form is not damaged.

I have tried loading the form back in to the form designer and it works, I have also resaved it and even tried saving it as an uncompressed form in case that was causing the issue.

Any further assistance would be appreciated.

Regards

Andrew

Elias Montoya

 The files i sent you are the most up to date Andrew. If you put them in the folder of the generated source code, Firefly might overwrite them.

So, first you have to close Firefly. Put the newest Egrid32 files in the Custom control's folder (Egrid32 folder), and open Firefly.

Now When firefly generates the source code, it will generate code with the newest files, allowing you to compile correctly as i sent it to you with no need of modifications.