

| Type | Description | |||
| Variant | A variant value that indicates the value of the event's parameter. |
Use the ID property to specify a specified even by its identifier. Use the ToString property to display information about fired event such us name, parameters, types and values. Use the CountParam property to count the parameters of an OLE event. Use the Param property to get the event's parameter. Use the Value property to specify the value of the parameter.
The following VB sample prints the events that an inside ActiveX control fires:
Private Sub ExMenu1_OleEvent(ByVal ID As Long, ByVal Ev As EXMENULibCtl.IOleEvent)
With ExMenu1.Item(ID)
Debug.Print (.Caption)
End With
With Ev
Debug.Print .Name
Dim i As Long
For i = 0 To .CountParam - 1
With .Param(i)
Debug.Print .Name & " = " & .Value
End With
Next
End With
End SubThe following C++ sample prints the events that an inside ActiveX control fires:
#import <exmenu.dll>
void OnOleEventExmenu1(long ID, LPDISPATCH Ev)
{
EXMENULib::IOleEventPtr spEvent( Ev );
OutputDebugString( spEvent->GetName() );
for ( long i = 0; i < spEvent->CountParam; i++ )
{
EXMENULib::IOleEventParamPtr spParam = NULL;
spEvent->get_Param( COleVariant( i ), &spParam );
CString strOutput;
strOutput.Format( "%s = %s", spParam->Name.operator const char *(), V2S( &spParam->Value ) );
OutputDebugString( strOutput );
}
}The C++ sample requires #import <exmenu.dll> to import definitions for OleEvent and OleEvenParam objects. It generates the EXMENULib namespace that includes all objects for the ExMenu component.
The V2S function converts a VARIANT value to a string expression:
static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
if ( pv )
{
if ( pv->vt == VT_ERROR )
return szDefault;
COleVariant vt;
vt.ChangeType( VT_BSTR, pv );
return V_BSTR( &vt );
}
return szDefault;
}The following VB.NET sample prints the events that an inside ActiveX control fires:
Private Sub AxExMenu1_OleEvent(ByVal sender As Object, ByVal e As AxEXMENULib._IMenuEvents_OleEventEvent) Handles AxExMenu1.OleEvent
With AxExMenu1.item(e.iD)
Debug.Print(.Caption)
End With
With e.ev
Debug.WriteLine(.Name())
Dim i As Integer
For i = 0 To .CountParam - 1
With .Param(i)
Debug.WriteLine(.Name + " = " + .Value.ToString())
End With
Next
End With
End SubThe following C# sample prints the events that an inside ActiveX control fires:
private void axExMenu1_OleEvent(object sender, AxEXMENULib._IMenuEvents_OleEventEvent e)
{
System.Diagnostics.Debug.WriteLine(axExMenu1[e.iD].Caption);
System.Diagnostics.Debug.WriteLine(e.ev.Name);
for (int i = 0; i < e.ev.CountParam; i++)
{
EXMENULib.OleEventParam param = e.ev[i];
System.Diagnostics.Debug.WriteLine( param.Name + " = " + param.Value.ToString());
}
}The following VFP sample prints the events that an inside ActiveX control fires:
*** ActiveX Control Event ***
LPARAMETERS id, ev
With thisform.ExMenu1.Item(ID)
wait window nowait (.Caption)
EndWith
With Ev
wait window nowait .Name
local i
For i = 0 To .CountParam - 1
With .Param(i)
wait window nowait .Name && + " = " + Str(.Value)
EndWith
Next
EndWith