The IEditorObjectTest interface must be implemented in order to define a custom filter for the contents of the DataSourceEditor dialog. The object that implements this interface must be passed to the DataSourceEditor by way of the AdviseOnEditorTest method in order to implement a custom filter.
|
Method |
Description |
|
OnEditorObjectTest |
This method is called for each object that may be displayed in the DataSourceEditor. If this method returns true, then the object will be displayed. If this method returns false, then the object will not be displayed. |
Sub DataSourceEditor_AdviseOnEditorObjectTest(data As DataSource)
Dim editor As New DataSourceEditor
editor.DataSource = data
editor.Caption = "Hello, my name is DataSourceEditor"
editor.ClassType = gcProjectedCoordSys
editor.issuer = "EPSG"
editor.code = "32611"
Dim filter As New DialogFilter
editor.AdviseOnEditorObjectTest filter
Dim selectedObject As ISerializable
Dim selectedObjType As ObjectType
Dim retVal As DialogState
retVal = editor.Show(selectedObject, selectedObjType)
editor.UnadviseOnEditorObjectTest
End Sub
' DialogFilter is defined in a separate class module like this:
Implements IEditorObjectTest
Implements IPickerObjectTest
Private Function IEditorObjectTest_OnEditorObjectTest(ByVal object As GeoCalcCOM.ISerializable) As Boolean
If object.Identifiers.Exists("EPSG") Then
IEditorObjectTest_OnEditorObjectTest = True
Else
IEditorObjectTest_OnEditorObjectTest = False
End If
End Function
Private Function IPickerObjectTest_OnPickerObjectTest(ByVal object As GeoCalcCOM.ISerializable) As Boolean
If object.Identifiers.Exists("EPSG") Then
IPickerObjectTest_OnEditorObjectTest = True
Else
IPickerObjectTest_OnEditorObjectTest = False
End If
End Function
procedure DataSourceEditor_AdviseOnEditorObjectTest(data : DataSource);
var
editor : DataSourceEditor;
filter : TDialogFilter;
selectedObj : ISerializable;
selectedObjType : ObjectType;
retVal : DialogState;
begin
editor := CoDataSourceEditor.Create;
editor.DataSource := data;
editor.ClassType := gcNoType;
editor.Caption := 'Hello, my name is DataSourceEditor';
editor.Issuer := 'EPSG';
editor.Code := '32611';
filter := TDialogFilter.Create;
editor.AdviseOnEditorObjectTest(filter);
retVal := editor.Show(selectedObj, selectedObjType);
editor.UnadviseOnEditorObjectTest;
end;
// In a separate unit, TDialogFilter is defined like this:
unit DialogFilter;
interface
uses
GeoCalcCOM_TLB, Dialogs, SysUtils;
type
TDialogFilter = class(TInterfacedObject, IEditorObjectTest, IPickerObjectTest)
public
function OnEditorObjectTest(const obj: ISerializable; out pVal: WordBool): HResult; stdcall;
function OnPickerObjectTest(const obj: ISerializable; out pVal: WordBool): HResult; stdcall;
end;
implementation
function TDialogFilter.OnEditorObjectTest(const obj: ISerializable; out pVal: WordBool): HResult; stdcall;
begin
if obj.Identifiers.Exists('EPSG') then
begin
pVal := true;
end
else
begin
pVal := false;
end;
end;
function TDialogFilter.OnPickerObjectTest(const obj: ISerializable; out pVal: WordBool): HResult; stdcall;
begin
if obj.Identifiers.Exists('EPSG') then
begin
pVal := true;
end
else
begin
pVal := false;
end;
end;
end.