![]() | Type | Description | ||
| Ed as Editor | An Editor object where the event occurs. | |||
| Key as Variant | A string expression that indicates the key of the button being pressed. |
The following VB sample displays the key of the button being clicked:
Private Sub Form_Load()
With Record1
With .Add("Calc", CalculatorType)
.Value = 3.14
.AddButton "AKey", , 1
.AddButton "BKey", , 2
End With
End With
End Sub
Private Sub Record1_ButtonClick(ByVal Ed As EXRECORDLibCtl.IEditor, ByVal Key As Variant)
Debug.Print Ed.Label & ", Key = """ & Key & """"
End Sub
The following VC sample displays the key of the button being clicked:
COleVariant vtMissing; vtMissing.vt = VT_ERROR;
CEditor editor = m_record.Add(COleVariant("Calc"), /*CalculatorType*/ 21, vtMissing );
editor.SetValue( COleVariant( 3.14 ) );
editor.AddButton( COleVariant( "AKey" ), vtMissing, COleVariant( (long) 1 ), vtMissing, vtMissing, vtMissing );
editor.AddButton( COleVariant( "BKey" ), vtMissing, COleVariant( (long) 1 ), vtMissing, vtMissing, vtMissing );
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;
}
void OnButtonClickRecord1(LPDISPATCH Ed, const VARIANT FAR& Key)
{
CEditor editor( Ed );
editor.m_bAutoRelease = FALSE;
TCHAR szOutput[1024];
wsprintf( szOutput, "%s, Key = \"%s\"\n", (LPCTSTR)editor.GetLabel(), (LPCTSTR)V2S( &(VARIANT&)Key ) );
OutputDebugString( szOutput );
}