English

How To: Use the Reverse method on the Points collection in Delphi

Summary

When the MapObjects LT type library is imported into Delphi, the Reverse method of the Points collection may not be wrapped correctly. In this case, the raw dispatch interface must be used.

Procedure

Use the IDispatch methods GetIDsOfNames and Invoke to call the Reverse method of the MapObjectsLT Points object.

  1. You will need to declare the following variables in addition to your MapObjectsLT::Points object:
    Code:
    var
    ClassDispatchInterface : IDispatch;
    Names : array [0..0] of PWideChar;
    NameDispIds : array [0..0] of TDispID;
    Params : TDispParams;

  2. Get the IDispatch interface of the MapObjectsLT Points object.
    Code:
    ClassDispatchInterface := pts;

  3. Call GetIDsOfNames to get the DispID of the method name.
    Code:
    Names[0] := StringToOleStr('Reverse');
    ClassDispatchInterface.GetIDsOfNames (GUID_NULL, @Names, 1, LOCALE_SYSTEM_DEFAULT,@NameDispIds);

  4. Call the method. There are no arguments for this method.
    Code:
    Params.rgvarg := nil;
    Params.rgdispidNamedArgs := nil;
    Params.cArgs := 0;
    Params.cNamedArgs := 0;
    ClassDispatchInterface.Invoke(NameDispIds[0], GUID_NULL, LOCALE_SYSTEM_DEFAULT,DISPATCH_METHOD, Params, nil,nil,nil);