Integrating EGrid with Firefly

Started by Peter Heffernan, September 02, 2011, 08:47:02 PM

Previous topic - Next topic

Peter Heffernan

Hello all,

A hobbyist VB type guy, I have had Firefly since purchasing PB some months ago but never really played with it too much, working with DDT for the most part.

Recently I decided to create a little project using the EGrid32Pro .dll and I am struggling to get some code fitted into how Firefly works, and thought best to ask for some assistance from you guys.

The code that I am trying to integrate into the Firefly version comes from the Egrid32 Form designer snippets 'Excel Navigation.snl', while this works fine writing DDT code I would like some advice on how to implement it using Firefly.

Basically I want to place three instances of EGrid32Pro onto a Firefly form and use them with the code snippet code from 'Excel Navigation.snl' (don't know that I could post it) but I'm sure someone knows of it.

I can get it working 'of a fashion', but get messed up with where the Declares are placed within Firefly.

A pointer to some more example code would probably do it.

Thanks.


Paul Squires

Can you attach the project that you have done so far? (less the EGrid DLL of course).
Paul Squires
PlanetSquires Software

Brian Chirgwin

Peter,

I'll try to create an example of this. 

I've taken over the rights to Egrid. http://www.powerbasic.com/support/pbforums/showthread.php?t=48507

Forums specific to egrid will be available soon.

Brian Chirgwin

Marc van Cauwenberghe

This news is really the thing that makes my day today.  :) :) :)
Egrid goes on!!!
If you need help, just mail me.

Best Regards,
Marc

Peter Heffernan

Quote from: TechSupport on September 03, 2011, 06:05:00 PM
Can you attach the project that you have done so far? (less the EGrid DLL of course).
Initially I thought that by using the FORM1_EGRID321_CUSTOM method, produced in the code, that I could paste a slightly altered vesion of the EGridNav code in there, like:

'--------------------------------------------------------------------------------
''=========================================================================================================
''DIALOG PROCEDURE
'CallBack Function MAINPROC As Long
'from EXCEL3 NAVIGATION.SNL snippet.
Function FORM1_EGRID321_CUSTOM ( _
                               ControlIndex  As Long,  _  ' index in Control Array
                               hWndForm      As Dword, _  ' handle of Form
                               hWndControl   As Dword, _  ' handle of Control
                               wMsg          As Long,  _  ' type of message
                               wParam        As Dword, _  ' first message parameter
                               lParam        As Long   _  ' second message parameter
                               ) As Long

Local  EGN           As EGRIDNOTIFY Ptr
'Code from EXCEL3 NAVIGATION.SNL snippet.
Local hShift     As Long
Local hControl   As Long
Local SELECTION  As Long
Local X          As Long
Local Y          As Long
Local TCell      As Byte
Local CCell      As Byte
Local LCell      As Byte
Local gSTOP      As Integer
Local Pt         As PointApi
'------------------------
Static MaxRows    As Long
Static MaxCols    As Long
Static ShftStat   As Byte
Static Expanding  As Long
Static vCols      As Integer
Static vRows      As Integer
Static CellEdit   As Byte
Static EGrid_ID   As Long           
Local astr As String

           
Select Case wmsg
'Code from EXCEL3 NAVIGATION.SNL snippet.

  Case %WM_INITDIALOG

  Case %WM_COMMAND

Case %WM_NOTIFY
  'EGN = CBLPARAM
'#######################
'# Replaced with:
  EGN = LParam
 
  'Code from EXCEL3 NAVIGATION.SNL snippet.
  gHndl = @EGN.HDR.hWndFrom                                'Get handle of current grid
  hControl = GetAsyncKeyState(%VK_Control)                 'Get Control key status
  hShift = GetAsyncKeyState(%VK_SHIFT)                     'Get Shift key status


  '------------------   Reset some values based on the need
  If EgridStat < 1 Then
    If g.X1 = 0 Then g.X1 = 1
    If g.Y1 = 0 Then g.Y1 = 1
    If g.X2 = 0 Then g.X2 = 1
    If g.Y2 = 0 Then g.Y2 = 1
    ShowRect(1)
    Undo = 0
    NumUndo = 0
    MaxUndo = 100 : Dim gUndo(MaxUndo+1)
  End If
  If EgridStat < 2 Then
    MaxRows = SendMessage(gHndl, %EG_GETMAXROWS, 0, 0)
    MaxCols = SendMessage(gHndl, %EG_GETMAXCOLUMNS, 0, 0)
        'IF the last column is hidden then make max rows one less
    Do
      If SendMessage(gHndl, %EG_GETHIDECOLUMN, MaxCols, 0) Then
        MaxCols = MaxCols - 1
      Else
        Exit Loop
      End If
    Loop
        'If the last row is hidden then make maxrows one less
    Do
      If SendMessage(gHndl, %EG_GETHIDEROW, MaxRows, 0) Then
        MaxRows = MaxRows - 1
      Else
        Exit Loop
      End If
    Loop
  End If

  EgridStat = 99

'  Select Case CbWParam
'   Case %EGRID_WINDOW
'#######################
'# Replaced with:
  Select Case wParam
   Case IDC_FORM1_EGRID321
:
:
:
etc (see attachement)


...but is seems that the appropriate wMsg's don't arrive at the FORM1_EGRID321_CUSTOM code, i.e. the WM_NOTIFY mesage never gets there.


From looking at the FireFly produced code for the FORM, the FORM1_EGRID321_CUSTOM function is called from within the FORM1_CODEPROCEDURE function, and, since that function wasn't calling the FORM1_EGRID321_CUSTOM proceduure with the wMsg that I needed I forced a call to FORM1_EGRID321_CUSTOM in the xxxx_FORM.inc file to arrive from the FORM1_FORMPROCEDURE function instead:

    ' The following CASE calls notification events from Controls on the Form and
    ' for any of these messages that the user is handling themselves.
    SELECT CASE wMsg

       CASE %WM_COMMAND

       CASE %WM_HSCROLL

       CASE %WM_VSCROLL

       CASE %WM_NOTIFY
          IF (@FLY_pNotify.idFrom = IDC_FORM1_EGRID321) THEN
            FLY_nResult = FORM1_EGRID321_CUSTOM (FLY_ControlIndex, HwndForm, @FLY_Pnotify.HwndFrom, wMsg, wParam, lParam)
            IF FLY_nResult THEN FUNCTION = FLY_nResult: EXIT FUNCTION
          END IF

    END SELECT

    ' Handle any custom messages if necessary.
                                                     

After re-compiling from PB that seem to work OK but I'm sure there's got to be a cleaner way of getting this done.

Attached is the FireFly file that I have been playing with

When compiled it does not get the Excel feel (like pressing the down key while editing moves you down) but by placing the above into CODEGEN_PROJECT1_FORM1_FORM.inc and recompiling CODEGEN_PROJECT1_MAIN.bas with PB then the custom function now gets the wMsg that I need.

What would be the best way of obtaining my desired result without this cludge?

Thanks.



Peter Heffernan

Having looked at this a little more now, it seems that the 'snippet' code was written for an earlier version of EGrid than I am using, so, rather than relying on that code I will re-write the parts that I will want for use.

I suppose that the ? still remains though; is there a means to get all the wMsg's into a CUSTOM function where WM_MODIFY is sent?

Thanks.

Paul Squires

I haven't looked closely at this but I would assume you need to use the CUSTOM handler for the Form rather than the Egrid control itself.
Paul Squires
PlanetSquires Software

Peter Heffernan

Quote from: TechSupport on September 05, 2011, 10:17:22 AM
I haven't looked closely at this but I would assume you need to use the CUSTOM handler for the Form rather than the Egrid control itself.

Thanks, 'guess if I had applied a little logic would have saved myself a post  :-[