Page 1 of 2
Problem getting an ActiveX component to work
Posted: Sun Jan 28, 2007 9:54 pm
by HennekensSM
Hello,
Just a few days a purchased an update of Fivewin in order to add GIS functionality to my program. The ActiveX component in questiopn is MapObjects. Most of the code seems to work fine (including events), but at one point I have no clue how to proceed. Please review the code below.
Regards,
Stephan
FUNCTION GIS()
LOCAL oWnd, oWndChild, oMap
LOCAL cEvents := ""
LOCAL oLayer, hLayers, nLayers
LOCAL hItem
DEFINE WINDOW oWndChild MDICHILD OF oWndMain()
oMap = TActiveX():New(oWndChild, "MapObjectsLT2.Map.1")
oMap:SetProp("Appearance", 1) // 3D
oMap:SetProp("ScrollBars", 1) // TRUE
oLayer := CreateObject("MapObjectsLT2.MapLayer")
oLayer:File := "d:\synbiosys\kaarten\prov2002.shp"
hLayers := oMap:GetProp("Layers")
// nLayers := OleGetProperty(hLayers, "Count")
// now we need to add the layer objects to the layers collection.
// using a VB-alike syntax it would be like 'oMap:Layers:Add(oLayer)'
// There is handle to the layers collection, hLayer, but how to add a layer
// to the layers collection????
oWndChild:oClient := oMap
oWndChild:Resize()
oWndChild:bResized := {|| oMap:Do("Refresh") }
oWndChild:bValid := {|| oMap:End(), oMap := NIL, TRUE }
RETURN(NIL)
Posted: Sun Jan 28, 2007 10:54 pm
by Silvio
where I can found MapObjects ?
Posted: Sun Jan 28, 2007 11:03 pm
by HennekensSM
http://www.esri.com/getting_started/dev ... jects.html
The lite version can be distributed royalty free.
I use MapObjects successfully with e.g Delphi, now I wish to include it in one of my Fivewin programs.
Regards,
Stephan
Posted: Mon Jan 29, 2007 9:59 am
by Silvio
can I see a function for delphi to translate in fw ?
you Know all methods of this activex
Posted: Mon Jan 29, 2007 10:05 am
by HennekensSM
Silvio,
as you have seen I got stuck with one important issue. I hope someone can help me out there. Before that I can not provide you with a working sample.
Regards,
Stephan
Posted: Mon Jan 29, 2007 10:29 am
by Antonio Linares
Stephan,
Please try this:
hLayers := oMap:GetProp("Layers")
OleInvoke( hLayers, "Add", oLayer )
// oMap:Layers:Add(oLayer)'
Posted: Mon Jan 29, 2007 10:39 am
by HennekensSM
Antonio,
I thing we made a step forward, but it's GPF's before showing the map. Scrollbars however already appear.
Regards,
Stephan
Posted: Mon Jan 29, 2007 10:42 am
by Silvio
I download Lt and install
I compiled your source test
it not found activex
you have the same error ?
Posted: Mon Jan 29, 2007 10:59 am
by HennekensSM
No, it does find the ActiveX component. For example CreateObject("MapObjectsLT2.MapLayer") works fine.
Stephan
Posted: Mon Jan 29, 2007 11:37 am
by Silvio
I have insert this but it call the activex copyright and then I can see only a white box
if you send me the completely test sample I can understand ...
Posted: Mon Jan 29, 2007 12:10 pm
by Silvio
Antonio
can you help u please ?
Posted: Mon Jan 29, 2007 12:26 pm
by Antonio Linares
Stephan,
What source code line is executing when it GPFs ?
Posted: Mon Jan 29, 2007 12:53 pm
by Silvio
it not run DO method
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd, oActiveX,oLayer
local cEvents := ""
DEFINE WINDOW oWnd TITLE "FiveWin ActiveX Gis Support"
oActiveX = TActiveX():New( oWnd, "MapObjectsLT2.Map.1" )
oWnd:oClient = oActiveX // To fill the entire window surface
oActiveX:SetProp("Appearance", 1) // 3D
oActiveX:SetProp("ScrollBars", 1) // TRUE
oLayer := CreateObject("MapObjectsLT2.MapLayer")
oLayer:Do( "Add", "d:\gis\karten\provincies.shp" )
* hLayers := oActiveX:GetProp("Layers")
* nLayers := OleGetProperty(hLayers, "Count")
ACTIVATE WINDOW oWnd
return nil
Application
===========
Path and name: C:\work\gis\gis.Exe (32 bits)
Size: 442,368 bytes
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 01/30/07, 13:49:27
Error description: Error MapObjectsLT2.MapLayer/16389 E_FAIL: DO
Args:
[ 1] = C Add
[ 2] = C d:\gis\karten\provincies.shp
Stack Calls
===========
Called from: win32ole.prg => TOLEAUTO:DO(0)
Called from: gis.prg => MAIN(20)
Posted: Mon Jan 29, 2007 1:15 pm
by Antonio Linares
Silvio,
CreateObject() returns an OLE object, not an ActiveX object that supports Do(). It has to be done the way we have pointed:
hLayers := oMap:GetProp("Layers")
OleInvoke( hLayers, "Add", oLayer )
Posted: Mon Jan 29, 2007 1:15 pm
by Silvio
Now run ok
Code: Select all
#include "FiveWin.ch"
function Main()
local oWnd, oActiveX,oLayer
local cEvents := ""
DEFINE WINDOW oWnd TITLE "FiveWin ActiveX Gis Support"
oActiveX = TActiveX():New( oWnd, "MapObjectsLT2.Map.1" )
oWnd:oClient = oActiveX // To fill the entire window surface
oActiveX:SetProp("Appearance", 1) // 3D
oActiveX:SetProp("ScrollBars", 1) // TRUE
oLayer := CreateObject("MapObjectsLT2.MapLayer")
oLayer:File := "d:\gis\sez_bari.shp"
hLayers := oActiveX:GetProp("Layers")
OleInvoke( hLayers, "Add", oLayer )
oWnd:Resize()
oWnd:bResized := {|| oActiveX:Do("Refresh") }
ACTIVATE WINDOW oWnd
return nil
Stephan,
the method refresh not run ok
How I can make to zoom it ?