DispId: Integer;
The DispId property returns dispatcher identifier of the event occurred for the object loaded to the component.
Dispatcher identifier (DISPID) is a unique value assigned to a certain event on development. Required values of dispatcher identifiers for certain events can be obtained in the special documentation for COM object, which is worked with.
Executing the example requires a form, a button named Button1 on it and the OleDocumentBox component. The Microsoft Excel sheet was loaded to the OleDocumentBox component.
Sub OleDocumentBox1OnOleDocumentEvent(Sender: IOleDocumentBox; Args: IOleDocumentBoxEventArgs);
Var
Sheet, Range: Variant;
Row, Column: Integer;
s: String;
Begin
If Args.DispId = 1559 Then //1559 is identifier of the SheetBeforeDoubleClick event of Microsoft Excel workbook
Sheet := Args.Params.Param(0);
s := Sheet.GetProperty("Name") As String;
Range := Args.Params.Param(1);
Column := Range.GetProperty("Column") As Integer;
Row := Range.GetProperty("Row") As Integer;
//Prevent from turning into edit mode
Args.Params.Param(2) := True;
End If;
End Sub OleDocumentBox1OnOleDocumentEvent;
The double-click with the main mouse button on the sheet cell is registered during execution of the OnOleDocumentEvent event. The event is handled for all workbook sheets and has the 1559 identifier, which passes three parameters:
The sheet, where the event is generated.
The cell, which is double-clicked. This parameter is a range and contains multiple parameters. The GetProperty method is used to parse it.
Logical parameter that determines whether it is prevented to turn the cell into the edit mode.
The "s" variable contains a sheet name, the Rows and Columns variables contain numbers of row and column of the cell, which is double-clicked. It is prohibited to turn into the edit mode.
See also: