West Wind Internet and Client Tools
pass by reference
Gravatar is a globally recognized avatar based on your email address. pass by reference
  Steve Howie
  All
  Mar 17, 2021 @ 07:26pm

Hi there, I am working with an activex control, MapWinGIS, that has all of the documentation in C#. I've been able to get quite a bit done, but one thing that is perplexing me is a function call that is supposed to pass an object reference to the control and receive back "an output array of long type" with index references of the shapes I need to manipulate. I am getting the function to return .t. that it is finding something, but the object reference doesn't seem to change no matter what I do. So, wwDotNetBridge to the rescue?

the line of offending code is:

lResult = sf.SelectShapes(ext, 500.0, 0, @oresult)

ext is an object that comes from the MapWinGIS object, which seems to be working fine. I have tried creating oResult as .null. (as the .net example shows), as a blank object type, as an empty array, and an array with integers=0 (not sure how to setup long integers) for several rows. Nothing seems to change through the COM object and definitely nothing comes back through the referenced variable.

Any thoughts as to how to get information back, either with wwDotNetBridge or otherwise?

Thanks in advance!

Gravatar is a globally recognized avatar based on your email address. re: pass by reference
  Rick Strahl
  Steve Howie
  Mar 17, 2021 @ 10:57pm

Take a look at the documentation here:

Passing Values by Reference (w/ wwDotnetBridge)

ActiveX controls that pass by reference should work with standard FoxPro @ syntax, but you have to make sure the values you're passing in are of the correct types and potentially initilized properly. COM does not like byRef values and it's always hit or miss whether that works with FoxPro.

.NET manages it in the wrapper or via the indirect referencing.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: pass by reference
  Steve Howie
  Steve Howie
  Mar 18, 2021 @ 08:53am

Yes, I'm afraid I may be hitting a bit of a dead end here as the object I'm working with is an ActiveX control that displays the map on the screen. I'm not sure how to get a reference to that object into wwDotNetBridge to get a value back. It seems no matter what I try to hand it by reference, the relationship must break somewhere in the COM structure as nothing gets updated. Running the function in .NET it seems to pass back a fairly simple zero based, integer array. At this point, I have the data that is being placed on the screen and I have the x & y coordinates of my mouse, so I may have to do my own searches back to the original data to display labels.

To ask the obvious, there's no way to get an activex control from my page into wwDotNetBridge so I can pull back this information? When I tried to pass in my thisform.axMap1 object reference to createinstance, it obviously didn't go anywhere. It seems to me that createinstance would, at best, create a new copy of this object, which won't help me search the info from the existing object.

Gravatar is a globally recognized avatar based on your email address. re: pass by reference
  Rick Strahl
  Steve Howie
  Mar 18, 2021 @ 02:36pm

If you're using wwDotnetBridge you should be able to use a ComValue() object to hold a reference to the Map. That object is an object wrapper that keeps the actual object in .NET - it never goes directly into FoxPro and you can pass it to a .NET method and the original value is pulled out.

So that part should be doable.

I'm confused by you talking about ActiveX and wwDotnetBridge - those are two different things obviously that have nothing to do with each other. If you're using an ActiveX control that wraps some .NET object, you're not interacting with .NET but with COM and most likely not even with a .NET wrapper around an object.

+++ Rick ---

© 1996-2021