Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GPS Control...

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Back to this GPS control!!!

I am just reading the documentation on the control and some of the METHODS require you to pass variables to the method for the return values, and the method itself returns T/F depending on whether it was successful or not. The example VB code is:

Dim dbLatitude As Double
Dim dbLongitude As Double

If objGPS.OSGridToLatLong(503333, 406785, dbLatitude, dbLongitude) Then ‘ convert position

MsgBox “Lat = “ & CStr(dbLatitude) & “ : Long = “ & CStr(dbLongitude)

Else

MsgBox “Conversion failed”

End If



...what would the VFP equivalent of this be?

TIA
Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
An equivilent to
Dim dbLatitude As Double
Dim dbLongitude As Double

would be something like

STORE 0 TO dbLatitude
STORE 0 TO dbLongitude

The rest goes something like:
Code:
DECLARE OSGridToLatLong IN 'SomeDLL.DLL' ;
   DOUBLE nX, ;
   DOUBLE nY, ;
   DOUBLE dbLatitude, ;
   DOUBLE dbLongitude
   
IF OSGridToLatLong(503333, 406785, dbLatitude, dbLongitude)
    MESSAGEBOX("Lat = " + Str(dbLatitude) + " : Long = " + Str(dbLongitude), 0, "Result")
Else
    MESSAGEBOX("Conversion failed", 0 , "Result")
EndIf

Of course it is untested, but you get the idea.
Dave S.
 
Hi Dave!

I'm afraid I am finding this all very confusing! This maybe it will become a project I wish I never started :(

Anyway, I put the code in that you specified, but I am getting the 'Cannot find entry point....' error when it hits the line

IF OSGridToLatLong(503333, 406785, dbLatitude, dbLongitude)

I have checked the help under DECLARE - DLL which states that the error is usually caused by not adhering to case sensitivity.

So I opened the control in the class browser only to find that it is correct.

In the browser the tree is as follows:

GPSControl
_GPSActiveXControl
OSGridToLatLong
etc..

Does this have any bearing?

Also I have created an object to the control:

loGPS = CREATEOBJECT('GPSControl.GPSActiveXControl')

...should I be using the object reference instead?

Cheers
Neil

"I like work. It fascinates me. I can sit and look at it for hours..."
 
You're right, you should use the object reference instead,
ie:

get rid of the declare:
DECLARE OSGridToLatLong IN 'SomeDLL.DLL' ;
DOUBLE nX, ;
DOUBLE nY, ;
DOUBLE dbLatitude, ;
DOUBLE dbLongitude


and use:
loGPS = CREATEOBJECT('GPSControl.GPSActiveXControl')

IF loGPS.OSGridToLatLong(503333, 406785, dbLatitude, dbLongitude)
MESSAGEBOX("Lat = " + Str(dbLatitude) + " : Long = " + Str(dbLongitude), 0, "Result")
Else
MESSAGEBOX("Conversion failed", 0 , "Result")
EndIf
 
Sorry I led you astray, I was thinking your control was a DLL. [blush]
I didn't realize it was ActiveX. That being the case, I would go along with wgcs.
Dave S.
 
Hi Dave!

It is a DLL! I think this is why I am getting so confused with it!! But it is initiated as described above.

WGCS - I tried what you said but I am getting 'Type Mismatch' error. How do I define a variable as double? Do I pass it as reference (ie @var)?

Thanks for the help it's much appreciated!

Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
Sorry guys my fault (give me a slap on the back of the head)!!!!!

I was storing 0 to both variables. I changed this to 0000000000.0000000000 and now it works!!!

I've got a headache...

Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
OK - 1 step forward 3 steps back!!!!

This DLL/ActiveX has a method to read various bits of data off the GPS. For example, to read the current position the method is:

? loGPS.ReadPosition() && returns -1 which means success

To access this data I would then issue the following (thanks to the above comments):

lnLatitude = 0000000000.0000000000
lnLongitude = 0000000000.0000000000

loGPS.GotPosition( @lnLatitude, @lnLongitude )

? lnLatitude
? lnLongitude

...BUT, at the GotPosition method I have the 'Unknown Name' error.

So I browsed the DLL again and find that this is the actual scenarion:

GPSControl
_GPSActiveXControl && single underscore
ReadPosition
GPSActiveXControl
__GPSActiveXControl && double underscore
GotPosition

AM I MISSING SOMETHING!!!! or should my loGPS have the GotPosition method? BTW - I am using their trial control whilst waiting for them to send me the 'real' one but I am assured that it is only timebombed not crippled.

TIA
Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
Right, it would appear the GotPosition() is an event not a method, but it should still be accessible to my object??

I have had a response from the DLL provider saying that in VB you have to delcare that you want to use events, ie:

Private Withevents objGPS as GPSControl.GPSActiveXControl

Is there a similar thing in VFP? I am rapidly coming to the conclusion that I will not be able to use this DLL :((

Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
Neil,
The best answer I can give is "maybe" in VFP 7.0+ you have the EVENTHANDLER( ) Function. I believe it'll give you what you need, although I haven't used it, so I'm not sure of the details.

Rick
 
You should be able to put the ActiveX object in an OLE Container on a form, and bind to the events that way.
 
Thanks for the responses, but I am stuck with VFP6 at the mo.

WGCS - Could you expand on this a bit please! Would I be able to write code in the events this way?

TIA
Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
I've now been told to look at VFPCOM.DLL.

Could be interesting! I will have to play with it later. Hope it works with VFP6!

Rick - Yes it is that EVENTHANDLER() function I need!



Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
You may have to assume GotPosition happened.
My suggestion would be to try and access the properties of the control and compare or store them somehow.
Dave S.
 
Hi Dave!

Unfortunately, GotPosition also returns the values I am after :(

Anyway, I have managed to have a quick play with the VFPCOM.DLL and managed to get an export of the events within the DLL.

But I still have problems with it!!!!

I will start a new thread about it but I am beginning to see a light at the end of the tunnel!

Cheers
Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
Hi Neil,

try the following:

MODI FORM testForm
( blank form appears )
Click the toolbar button with the letters "OLE" on it, and the tooltip "ActiveX Control (OleControl)".
Click on the form (to place the control)
( Insert Object Dialog appears )
Select the radio button "Insert Control"
( the object type list will eventually fill with all activeX controls registered on your computer )

Find the 'GPSControl.GPSActiveXControl' in the list... it may go by a slightly different name in this list (which I find annoying), but when you have clicked it, the "Result" frame at the bottom will contain the full path to the proper .DLL file, and the control's GUID.

Click "OK"
( The control will be inserted, and selected, on the form )

Go to the properties window ( If it's not yet visible, right click the new control and choose "Properties" )

Select the "Methods" tab in the properties window.

Find the "GotPosition Event", double click it, and put code in the code window that appears.

This code will be executed when the GotPosition event fires.

...
This binding to events cannot be done in source code without the VFP7 EventHandler function.
 
Thanks for the input WGCS!

Unfortunately this is what I originally tried. I even got the ActiveX developers looking into it and they couldn't add the control this way either!!

So they suggested the VFPCOM.DLL which I have tried and got further with it but have started a new thread about it as it still doesn't work!

Thanks for your time.

Neil "I like work. It fascinates me. I can sit and look at it for hours..."
 
Ok, Sorry for offering false hope then...

What error happens when trying to add it this way?
 
There's not particular error but there is no visual element to this control (so the developer tells me) which is probably why it doesn't appear on the list.

If I add it from file, I still do not get any reference to it's properties/methods/events. "I like work. It fascinates me. I can sit and look at it for hours..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top