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
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??
> 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).