'Event--------'此部分为tlbviewer导出
Const IID__IVSFlexGridEvents = "{C0A63B84-4B21-11D3-BD95-D426EF2C7949}"
Type VSFlexGrid__IVSFlexGridEvents Extends CIDispatch
Declare Function Invoke(ByVal dispIdMember As DISPID, ByVal riid As Const IID Const Ptr, ByVal lcid As LCID, ByVal wFlags As WORD, ByVal pDispParams As DISPPARAMS Ptr, ByVal pVarResult As VARIANT Ptr, ByVal pExcepInfo As EXCEPINFO Ptr, ByVal puArgErr As UINT Ptr) As HRESULT
Declare Constructor()
On_Click As SUB()
On_DblClick As SUB()
On_KeyDown As SUB(ByRef KeyCode As Short,ByVal Shift As Short)
On_KeyPress As SUB(ByRef KeyAscii As Short)
On_KeyUp As SUB(ByRef KeyCode As Short,ByVal Shift As Short)
On_MouseDown As SUB(ByVal Button As Short,ByVal Shift As Short,ByVal X As Single,ByVal Y As Single)
On_MouseMove As SUB(ByVal Button As Short,ByVal Shift As Short,ByVal X As Single,ByVal Y As Single)
On_MouseUp As SUB(ByVal Button As Short,ByVal Shift As Short,ByVal X As Single,ByVal Y As Single)
On_SelChange As SUB()
On_RowColChange As SUB()
On_EnterCell As SUB()
On_LeaveCell As SUB()
On_BeforeMouseDown As SUB(ByVal Button As Short,ByVal Shift As Short,ByVal X As Single,ByVal Y As Single,ByRef Cancel As VARIANT_BOOL)
On_BeforeRowColChange As SUB(ByVal OldRow As Long,ByVal OldCol As Long,ByVal NewRow As Long,ByVal NewCol As Long,ByRef Cancel As VARIANT_BOOL)
On_AfterRowColChange As SUB(ByVal OldRow As Long,ByVal OldCol As Long,ByVal NewRow As Long,ByVal NewCol As Long)
On_BeforeSelChange As SUB(ByVal OldRowSel As Long,ByVal OldColSel As Long,ByVal NewRowSel As Long,ByVal NewColSel As Long,ByRef Cancel As VARIANT_BOOL)
On_AfterSelChange As SUB(ByVal OldRowSel As Long,ByVal OldColSel As Long,ByVal NewRowSel As Long,ByVal NewColSel As Long)
On_BeforeScroll As SUB(ByVal OldTopRow As Long,ByVal OldLeftCol As Long,ByVal NewTopRow As Long,ByVal NewLeftCol As Long,ByRef Cancel As VARIANT_BOOL)
On_AfterScroll As SUB(ByVal OldTopRow As Long,ByVal OldLeftCol As Long,ByVal NewTopRow As Long,ByVal NewLeftCol As Long)
On_Compare As SUB(ByVal Row1 As Long,ByVal Row2 As Long,ByRef Cmp As Short)
On_BeforeSort As SUB(ByVal Col As Long,ByRef Order As Short)
On_AfterSort As SUB(ByVal Col As Long,ByRef Order As Short)
On_BeforeMoveColumn As SUB(ByVal Col As Long,ByRef Position As Long)
On_AfterMoveColumn As SUB(ByVal Col As Long,ByRef Position As Long)
On_BeforeUserResize As SUB(ByVal Row As Long,ByVal Col As Long,ByRef Cancel As VARIANT_BOOL)
On_AfterUserResize As SUB(ByVal Row As Long,ByVal Col As Long)
On_BeforeCollapse As SUB(ByVal Row As Long,ByVal State As Short,ByRef Cancel As VARIANT_BOOL)
On_AfterCollapse As SUB(ByVal Row As Long,ByVal State As Short)
On_BeforeEdit As SUB(ByVal Row As Long,ByVal Col As Long,ByRef Cancel As VARIANT_BOOL)
On_StartEdit As SUB(ByVal Row As Long,ByVal Col As Long,ByRef Cancel As VARIANT_BOOL)
On_ValidateEdit As SUB(ByVal Row As Long,ByVal Col As Long,ByRef Cancel As VARIANT_BOOL)
On_AfterEdit As SUB(ByVal Row As Long,ByVal Col As Long)
On_KeyPressEdit As SUB(ByVal Row As Long,ByVal Col As Long,ByRef KeyAscii As Short)
On_KeyDownEdit As SUB(ByVal Row As Long,ByVal Col As Long,ByRef KeyCode As Short,ByVal Shift As Short)
On_KeyUpEdit As SUB(ByVal Row As Long,ByVal Col As Long,ByRef KeyCode As Short,ByVal Shift As Short)
On_ChangeEdit As SUB()
On_BeforePageBreak As SUB(ByVal Row As Long,ByRef BreakOK As VARIANT_BOOL)
On_GetHeaderRow As SUB(ByVal Row As Long,ByRef HeaderRow As Long)
On_StartPage As SUB(ByVal hDC As Long,ByVal Page As Long,ByRef Cancel As VARIANT_BOOL)
On_DrawCell As SUB(ByVal hDC As Long,ByVal Row As Long,ByVal Col As Long,ByVal Left As Long,ByVal Top As Long,ByVal Right As Long,ByVal Bottom As Long,ByRef Done As VARIANT_BOOL)
On_Error As SUB(ByVal ErrorCode As Long,ByRef ShowMsgBox As VARIANT_BOOL)
On_CellButtonClick As SUB(ByVal Row As Long,ByVal Col As Long)
On_BeforeScrollTip As SUB(ByVal Row As Long)
On_AfterUserFreeze As SUB()
On_OLEStartDrag As SUB(ByRef Data As CObject,ByRef AllowedEffects As Long)
On_OLEGiveFeedback As SUB(ByRef Effect As Long,ByRef DefaultCursors As VARIANT_BOOL)
On_OLESetData As SUB(ByRef Data As CObject,ByRef DataFormat As Short)
On_OLECompleteDrag As SUB(ByRef Effect As Long)
On_OLEDragOver As SUB(ByRef Data As CObject,ByRef Effect As Long,ByVal Button As Short,ByVal Shift As Short,ByVal X As Single,ByVal Y As Single,ByRef State As Short)
On_OLEDragDrop As SUB(ByRef Data As CObject,ByRef Effect As Long,ByVal Button As Short,ByVal Shift As Short,ByVal X As Single,ByVal Y As Single)
On_OLESetCustomDataObject As SUB(ByRef CustomDataObject As CObject)
On_CellChanged As SUB(ByVal Row As Long,ByVal Col As Long)
On_BeforeMoveRow As SUB(ByVal Row As Long,ByRef Position As Long)
On_AfterMoveRow As SUB(ByVal Row As Long,ByRef Position As Long)
On_SetupEditWindow As SUB(ByVal Row As Long,ByVal Col As Long,ByVal EditWindow As Long,ByVal IsCombo As VARIANT_BOOL)
End Type
Constructor VSFlexGrid__IVSFlexGridEvents()
IIDFromString(IID__IVSFlexGridEvents, @Base.EventIID)
End Constructor
Function VSFlexGrid__IVSFlexGridEvents.Invoke(ByVal dispIdMember As DISPID, ByVal riid As Const IID Const Ptr, ByVal lcid As LCID, ByVal wFlags As WORD, ByVal pDispParams As DISPPARAMS Ptr, ByVal pVarResult As VARIANT Ptr, ByVal pExcepInfo As EXCEPINFO Ptr, ByVal puArgErr As UINT Ptr) As HRESULT
Select Case dispIdMember
Case &HFFFFFDA8 'Click
If On_Click then On_Click()
Case &HFFFFFDA7 'DblClick
If On_DblClick then On_DblClick()
Case &HFFFFFDA6 'KeyDown
If On_KeyDown then On_KeyDown(pDispParams->rgvarg[0].iVal,pDispParams->rgvarg[1].iVal)
Case &HFFFFFDA5 'KeyPress
If On_KeyPress then On_KeyPress(pDispParams->rgvarg[0].iVal)
Case &HFFFFFDA4 'KeyUp
If On_KeyUp then On_KeyUp(pDispParams->rgvarg[0].iVal,pDispParams->rgvarg[1].iVal)
Case &HFFFFFDA3 'MouseDown
If On_MouseDown then On_MouseDown(pDispParams->rgvarg[0].iVal,pDispParams->rgvarg[1].iVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal)
Case &HFFFFFDA2 'MouseMove
If On_MouseMove then On_MouseMove(pDispParams->rgvarg[0].iVal,pDispParams->rgvarg[1].iVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal)
Case &HFFFFFDA1 'MouseUp
If On_MouseUp then On_MouseUp(pDispParams->rgvarg[0].iVal,pDispParams->rgvarg[1].iVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal)
Case &H1 'SelChange
If On_SelChange then On_SelChange()
Case &H2 'RowColChange
If On_RowColChange then On_RowColChange()
Case &H3 'EnterCell
If On_EnterCell then On_EnterCell()
Case &H4 'LeaveCell
If On_LeaveCell then On_LeaveCell()
Case &H5 'BeforeMouseDown
If On_BeforeMouseDown then On_BeforeMouseDown(pDispParams->rgvarg[0].iVal,pDispParams->rgvarg[1].iVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal,pDispParams->rgvarg[4].boolVal)
Case &H6 'BeforeRowColChange
If On_BeforeRowColChange then On_BeforeRowColChange(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].lVal,pDispParams->rgvarg[4].boolVal)
Case &H7 'AfterRowColChange
If On_AfterRowColChange then On_AfterRowColChange(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].lVal)
Case &H8 'BeforeSelChange
If On_BeforeSelChange then On_BeforeSelChange(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].lVal,pDispParams->rgvarg[4].boolVal)
Case &H9 'AfterSelChange
If On_AfterSelChange then On_AfterSelChange(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].lVal)
Case &HA 'BeforeScroll
If On_BeforeScroll then On_BeforeScroll(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].lVal,pDispParams->rgvarg[4].boolVal)
Case &HB 'AfterScroll
If On_AfterScroll then On_AfterScroll(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].lVal)
Case &HC 'Compare
If On_Compare then On_Compare(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].iVal)
Case &HD 'BeforeSort
If On_BeforeSort then On_BeforeSort(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].iVal)
Case &HE 'AfterSort
If On_AfterSort then On_AfterSort(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].iVal)
Case &HF 'BeforeMoveColumn
If On_BeforeMoveColumn then On_BeforeMoveColumn(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H10 'AfterMoveColumn
If On_AfterMoveColumn then On_AfterMoveColumn(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H11 'BeforeUserResize
If On_BeforeUserResize then On_BeforeUserResize(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].boolVal)
Case &H12 'AfterUserResize
If On_AfterUserResize then On_AfterUserResize(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H13 'BeforeCollapse
If On_BeforeCollapse then On_BeforeCollapse(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].iVal,pDispParams->rgvarg[2].boolVal)
Case &H14 'AfterCollapse
If On_AfterCollapse then On_AfterCollapse(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].iVal)
Case &H15 'BeforeEdit
If On_BeforeEdit then On_BeforeEdit(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].boolVal)
Case &H16 'StartEdit
If On_StartEdit then On_StartEdit(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].boolVal)
Case &H17 'ValidateEdit
If On_ValidateEdit then On_ValidateEdit(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].boolVal)
Case &H18 'AfterEdit
If On_AfterEdit then On_AfterEdit(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H19 'KeyPressEdit
If On_KeyPressEdit then On_KeyPressEdit(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].iVal)
Case &H1A 'KeyDownEdit
If On_KeyDownEdit then On_KeyDownEdit(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal)
Case &H1B 'KeyUpEdit
If On_KeyUpEdit then On_KeyUpEdit(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal)
Case &H1C 'ChangeEdit
If On_ChangeEdit then On_ChangeEdit()
Case &H1D 'BeforePageBreak
If On_BeforePageBreak then On_BeforePageBreak(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].boolVal)
Case &H1E 'GetHeaderRow
If On_GetHeaderRow then On_GetHeaderRow(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H1F 'StartPage
If On_StartPage then On_StartPage(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].boolVal)
Case &H20 'DrawCell
If On_DrawCell then On_DrawCell(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].lVal,pDispParams->rgvarg[4].lVal,pDispParams->rgvarg[5].lVal,pDispParams->rgvarg[6].lVal,pDispParams->rgvarg[7].boolVal)
Case &H21 'Error
If On_Error then On_Error(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].boolVal)
Case &H22 'CellButtonClick
If On_CellButtonClick then On_CellButtonClick(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H23 'BeforeScrollTip
If On_BeforeScrollTip then On_BeforeScrollTip(pDispParams->rgvarg[0].lVal)
Case &H24 'AfterUserFreeze
If On_AfterUserFreeze then On_AfterUserFreeze()
Case &H25 'OLEStartDrag
If On_OLEStartDrag then On_OLEStartDrag(pDispParams->rgvarg[0],pDispParams->rgvarg[1].lVal)
Case &H26 'OLEGiveFeedback
If On_OLEGiveFeedback then On_OLEGiveFeedback(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].boolVal)
Case &H27 'OLESetData
If On_OLESetData then On_OLESetData(pDispParams->rgvarg[0],pDispParams->rgvarg[1].iVal)
Case &H28 'OLECompleteDrag
If On_OLECompleteDrag then On_OLECompleteDrag(pDispParams->rgvarg[0].lVal)
Case &H29 'OLEDragOver
If On_OLEDragOver then On_OLEDragOver(pDispParams->rgvarg[0],pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal,pDispParams->rgvarg[4].iVal,pDispParams->rgvarg[5].iVal,pDispParams->rgvarg[6].iVal)
Case &H2A 'OLEDragDrop
If On_OLEDragDrop then On_OLEDragDrop(pDispParams->rgvarg[0],pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].iVal,pDispParams->rgvarg[3].iVal,pDispParams->rgvarg[4].iVal,pDispParams->rgvarg[5].iVal)
Case &H2F 'OLESetCustomDataObject
If On_OLESetCustomDataObject then On_OLESetCustomDataObject(pDispParams->rgvarg[0].pvarVal)
Case &H2B 'CellChanged
If On_CellChanged then On_CellChanged(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H2C 'BeforeMoveRow
If On_BeforeMoveRow then On_BeforeMoveRow(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H2D 'AfterMoveRow
If On_AfterMoveRow then On_AfterMoveRow(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal)
Case &H2E 'SetupEditWindow
If On_SetupEditWindow then On_SetupEditWindow(pDispParams->rgvarg[0].lVal,pDispParams->rgvarg[1].lVal,pDispParams->rgvarg[2].lVal,pDispParams->rgvarg[3].boolVal)
End Select
Return S_OK
End Function
dim Shared Ocx as CObject
sub On_BeforeSelChange(ByVal OldRowSel As Long ,ByVal OldColSel As Long ,ByVal NewRowSel As Long ,ByVal NewColSel As Long ,ByRef Cancel As VARIANT_BOOL)'此为事件
Debug.Print NewRowSel ,NewColSel
Debug.Print Ocx.Get("TextMatrix" ,NewRowSel ,NewColSel).ToString'调用TextMatrix属性显示值
End Sub
Ocx.IsDebug = True'设置是否显示Debug错误信息
Ocx.CreateObjectFromLib("Vsflex7L.ocx" ,"{C0A63B86-4B21-11D3-BD95-D426EF2C7949}")'创建Vsflex7L组件
if Ocx.IsErr Then Exit sub'如果发现错误退出当前过程
Ocx.AttachControl Me.Custom1.hWnd'将此控件附加到任意控件上,大小与此控件相同
Static e as VSFlexGrid__IVSFlexGridEvents'定义一个事件接收对象,要为静态、全局或指针,否则在过程后此变量消失,产生回调失败
e.On_BeforeSelChange = cast(any ptr ,@On_BeforeSelChange)'实现一个选择前事件
Ocx.WithEvents(e)'调用此事件
var i =0 ,j=0 ,c=0
For i = 0 To 9
For j = 0 To 9
ocx.put("TextMatrix" ,i ,j ,"dddd" & Str(c))'循环赋值
if ocx.IsErr Then 判断是否失败
debug.print Ocx.ErrDescription'打印错误
Exit sub
End If
c+=1
next
Next