IPickerObjectTest Interface

The IPickerObjectTest interface must be implemented in order to define a custom filter for the contents of the DataSourcePicker dialog.  The object that implements this interface must be passed to the DataSourcePicker by way of the AdviseOnEditorTest method in order to implement a custom filter.

 

Methods

Method

Description

OnPickerObjectTest

This method is called for each object that may be displayed in the DataSourcePicker.  If this method returns true, then the object will be displayed.  If this method returns false, then the object will not be displayed.

 

Example

[VB6]

Sub DataSourcePicker_AdviseOnPickerObjectTest(data As DataSource)

    Dim picker As New DataSourcePicker

    picker.DataSource = data

    picker.Caption = "Hello, my name is DataSourcePicker"

    picker.ClassType = gcFittedCoordSys Or gcGeocentricCoordSys Or gcGeodeticCoordSys Or gcProjectedCoordSys

    picker.issuer = "EPSG"

    picker.code = "32611"

    

    Dim filter As New DialogFilter

    picker.AdviseOnPickerObjectTest filter

    

    Dim selectedObj As ISerializable

    Dim selectedObjType As ObjectType

    Dim retVal As DialogState

    

    retVal = picker.Show(selectedObj, selectedObjType)

    

    picker.UnadviseOnPickerObjectTest

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

 

[Delphi 7]

procedure DataSourcePicker_AdviseOnPickerObjectTest(data : DataSource);

var

  picker : DataSourcePicker;

  filter : TDialogFilter;

  selectedObj : ISerializable;

  selectedObjType : ObjectType;

  retVal : DialogState;

begin

  picker := CoDataSourcePicker.Create;

  picker.DataSource := data;

  picker.Caption := 'Hello, my name is DataSourcePicker';

  picker.ClassType := gcFittedCoordSys or gcGeocentricCoordSys or gcGeodeticCoordSys or gcProjectedCoordSys;

  picker.Issuer := 'EPSG';

  picker.Code := '32611';

  filter := TDialogFilter.Create;

  picker.AdviseOnPickerObjectTest(filter);

  retVal := picker.Show(selectedObj, selectedObjType);

  picker.UnadviseOnPickerObjectTest;

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.