Author Topic: How to get eGrid notifications in FireFly?  (Read 1840 times)

John Montenigro

  • Newbie
  • *
  • Posts: 1
How to get eGrid notifications in FireFly?
« on: October 02, 2017, 10:28:22 am »
I've been using Firefly for awhile, and I've had the eGrid Pro grid for a couple of years, but I'm only just now trying to use them together.

I've made a lot of progress getting my grid created, columns sized, headers in place in color, columns read-only, and even column formats set!

But one thing that is now eluding me has to do with limiting the characters and the length of the string that the user can enter into a given cell.

As best I can tell, you cannot set a character string "filter" on a column, but it does seem that you can set such a filter "per-cell" or globally.

In order to set the "global" filter string, I have to use %EG_SETCHARACTERLIST. (I copied the sample code...)

Then, in order to switch to the global filter, I have to detect when the user starts editing a particular cell and invoke %EG_SetFilterMode to %EG_ALLOWCHARACTERS (I think!)

Then I have to detect when the user finishes editing, I switch to "all characters" (no filter) by invoking %EG_SetFilterMode to %EG_ALLOWALL

My problem is: HOW DO I DETECT the EGN_STARTEDEDITION  and EGN_FINISHEDIT notification messages?

I've tried to use the Firefly-specific "CUSTOM" routine, but it looks like that's not communicating with eGrid...

Code: [Select]
                                         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

   'I *think* this is how/where we will detect when a user begins editing a cell...
   Local lRet As Long, sTemp as string   

   Local X     As Long
   Local Y     As Long
   Local CurX  As Long
   Local CurY  As Long

   Local EGN As EgridNotify Ptr   ' Egrid32 Notification structure pointer

   Select Case wMsg


   Case %WM_NOTIFY

'      If wParam <> hWndControl Then Exit Select        '  is this best?   ...not sure...

      EGN = lParam  ' this is OK

      CurX = @EGN.Cell.x   ' this is the main selected cell in a multi-cell selection...
      CurY = @EGN.Cell.y

      ? "We should have X and Y",,"DEVTEST"      ' NOT DISPLAYING!!!!   So, then how to catch eGrid notifications!!????

      Select Case @EGN.HDR.Code        ' catch eGrid messages

      Case %EGN_STARTEDEDITION                                    ' or?       %EGN_STARTEDIT        %GC_STARTEDIT               '    how to detect? !!!!!

         ? "You started to edit cell: " & Trim$(@EGN.Cell.X) & ", "  &  Trim$(@EGN.Cell.Y)      ' this is the main selected cell in a multi-cell selection...

         If x = %GridColIngActAmt Or x = %GridColProgWt  Then 
            lRet = SendMessage(hGrid, %EG_SETFILTERMODE, %EG_ALLOWCHARACTERS Or %EG_IGNORECASE, 0)       ' when editing numeric cells
         End If

'         'Get the current entered value
'         sTemp  = Cell_GetText(CurX, CurY)

      Case %EGN_EDITIONCLOSED                           ' or?     EGN_CANCELEDIT    %EGN_FINISHEDIT     
         ? "You finished editing cell: " & Trim$(@EGN.Cell.X) & ", "  &  Trim$(@EGN.Cell.Y)

         lRet = SendMessage(hGrid, %EG_SETFILTERMODE, %EG_ALLOWALL, 0)                                ' when editing non-numeric cells

      End Select

   End Select

End Function

Can anyone spot what I'm doing wrong? I'd greatly appreciate guidance from a wiser, more experienced coder!