PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Michael Meeks on April 09, 2015, 03:53:22 PM

Title: Event for OCX not working as coded
Post by: Michael Meeks on April 09, 2015, 03:53:22 PM
Hi Techies  :'(

I'm Attempting to check if an event was fired...
Not sure what I'm doing wrong -  Any thoughts ?

Thanks



' Form1

Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long


    Local pFLEXDispatch As IVSFlexGrid
    Local pFLEXEvents As IVSFlexGridEventsImpl

    ' Get a reference to the Vsflexgrid1 control and set the properties
    pFLEXDispatch = OC_GetDispatch(HWND_FORM1_VSFLEXGRID1)

    ' Set Params
    If IsObject(pFLEXDispatch) Then
   
      ' Set Grid Rows & Cols
      pFLEXDispatch.Rows = 20
      pFLEXDispatch.Cols = 6
     
      pFLEXDispatch.Enabled = 1
      pFLEXDispatch.ExtendLastCol = 1
      pFLEXDispatch.Editable = 2
      pFLEXDispatch.AllowUserResizing = 1
      pFLEXDispatch.Row = 1
      pFLEXDispatch.Col = 1
      pFLEXDispatch.Sort = 1
      pFLEXDispatch.FocusRect = 3
      pFLEXDispatch.HighLight = 0

      ' Everything above works as expected

      ' Connect to the Events fired by the control
      pFLEXEvents = Class "CIVSFlexGridEvents"
      OC_Advise HWND_FORM1_VSFLEXGRID1, pFLEXEvents
      pFLEXEvents = Nothing
           
    End If

End Function

'Module1.inc

   Method KeyDown <-602> ( _
     ByRef prm_KeyCode As Integer _                     ' [in][out] *KeyCode VT_I2 <Integer>
   , ByVal prm_Shift As Integer _                       ' Shift VT_I2 <Integer>
   )                                                    ' void

     ' *** Insert your code here ***

     Local pFLEXDispatch As IVSFlexGrid
     
     ' Get a ref
      pFLEXDispatch = OC_GetDispatch(HWND_FORM1_VSFLEXGRID1)
     
      If IsObject(pVFLEXDispatch) Then
        pFLEXDispatch.TextMatrix(1,1) = "Good"    ' Puts text in Row1 Cell1 of the Grid
        pFLEXDispatch = Nothing
      End If
     
   End Method

Title: Re: Event for OCX not working as coded
Post by: Paul Squires on April 14, 2015, 10:45:00 PM
I don't have this grid control on my system. Is it free to install or do I need to buy it as part of Visual Basic or Visual Studio maybe??
Title: Re: Event for OCX not working as coded
Post by: José Roca on April 15, 2015, 05:58:35 AM
> OC_Advise HWND_FORM1_VSFLEXGRID1, pFLEXEvents

It is always advisable to check the result of a function call. If the call to OC_Advise returns 0, it means that it has failed.

For some reason, connection with the events of some OCXs fail when OC_Advise uses the PowerBASIC statement EVENTS FROM, which is the way used if you don't pass the IID of the events interface. Therefore, use:

OC_Advise HWND_FORM1_VSFLEXGRID1, pFLEXEvents, <IID of the events interface> (not shown in your code).