
4-6 Using the MintMT ActiveX Control
// Try function call
try
{
// Enable the drive
m_controller.setDriveEnable ( 0, true );
}
// Catch any errors
catch ( COleDispatchException *pe )
{
// Check the error code
switch ( pe->m_wCode )
{
case erMOTION_ERROR:
MessageBox ( "Drive in error, please re-start" );
break;
default:
pe->ReportError();
break;
}
pe->Delete();
}
The error code is part of the COleDispatchException class and can be accessed using the member
variable m_wCode.
All error codes are defined in the format erXXXX in the header file HOST_DEF.H that can be included in
Visual C++ files.
The same example in Visual Basic would be:
Private Sub Command1_Click()
' If an error occurs continue processing
On Error GoTo Handle_Errors
' Enable the drive
MintController.setDriveEnable 0, True
End Sub
Sub Handle_Errors()
' Check the error code
Select Case Err.Number
Case erMOTION_ERROR
MsgBox "Drive in error, please re-start"
Case Else
MsgBox Err.Description
End Select
End Sub
MintController is the name of the MintMT ActiveX control in the project.
The error code can be accessed using the Err structure. The element Number contains the error code.
Comentarios a estos manuales