Problem with Developer/2000 and OLE Importer

From: Alan Beiagi <abeiagi_at_geosys.com>
Date: 1998/03/18
Message-ID: <6epqsa$sgv1_at_atlas.geosys.com>#1/1


Hi Everyone,

I have a pretty complex question regarding ActiveX controls and Developer/2000 v2.0. I have used Form Builder's OLE importer to import the methods and properties of an ActiveX control into a program unit. This particular ActiveX control draws maps on a canvas, and has a method which takes the x,y coordinates on the screen and converts them to Latitude, Longitudes. The C++ prototype (Spec.) for this method is:

BOOL MapCtl.PixToLatLng(int x, int y, double* pLat, double* pLng);

Thus this method takes two integers and two _pointers_ (OUT variables) to double values. And then returns the Latitude, Longitude in pLat and pLng. It also returns a boolean value to indicate if the function succeeded.

When I used "OLE importer" it completely ignored the fact the Lat and Lng need to be OUT variables, and created the following function spec. Which is totally useless.

FUNCTION PixToLatLng(interface OleObj, x NUMBER, y NUMBER,  Lat NUMBER, Lng NUMBER) RETURN NUMBER IS

So then I went into the package body, and changed the code myself to the following. However after this code executes the values of Lat, and Lng are always null.

Does anybody have any idea what the problem might be here. Any problem will be greatly appreciated.

FUNCTION PixToLatLng(interface OleObj, x NUMBER, y NUMBER,  Lat OUT NUMBER, Lng OUT NUMBER) RETURN NUMBER IS   my_new_value NUMBER;

  ov1 OleVar;
  ov2 OleVar;
  ov3 OleVar;
  ov4 OleVar;
  ov5 OleVar;
  ov6 OleVar;

BEGIN   Init_OleArgs(4);
  Add_OleArg(x, VT_I2);
  Add_OleArg(y, VT_I2);

  ov1 := TO_VARIANT(Lat, VT_R8, False);
  ov2 := VAR_TO_VARPTR(ov1, VT_BYREF);
  Add_OleArg(ov2);

  ov3 := To_Variant(Lng, VT_R8, False);
  ov4 := Var_To_VarPtr(ov3, VT_BYREF);
  Add_OleArg(ov4);

  my_new_value := Call_Ole_Num(interface, 41);

  ov5 := VarPtr_To_Var(ov2);
  Lat := Var_To_Number(ov5);

  ov6 := VarPtr_To_Var(ov4);
  Lng := Var_To_Number(ov6);

  DESTROY_VARIANT(ov1);
  DESTROY_VARIANT(ov2);
  DESTROY_VARIANT(ov3);
  DESTROY_VARIANT(ov4);
  DESTROY_VARIANT(ov5);
  DESTROY_VARIANT(ov6);


  return my_new_value;
End; Received on Wed Mar 18 1998 - 00:00:00 CET

Original text of this message