Problem getting an ActiveX component to work
-
- Posts: 17
- Joined: Sun Jan 28, 2007 11:47 am
Problem getting an ActiveX component to work
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)
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)
-
- Posts: 17
- Joined: Sun Jan 28, 2007 11:47 am
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
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
-
- Posts: 17
- Joined: Sun Jan 28, 2007 11:47 am
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
-
- Posts: 17
- Joined: Sun Jan 28, 2007 11:47 am
-
- Posts: 17
- Joined: Sun Jan 28, 2007 11:47 am
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
it not run DO method
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)
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)
Best Regards, Saludos
Falconi Silvio
Falconi Silvio
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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 )
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 )
Last edited by Antonio Linares on Mon Jan 29, 2007 1:18 pm, edited 2 times in total.
Now run ok
Stephan,
the method refresh not run ok
How I can make to zoom it ?
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
the method refresh not run ok
How I can make to zoom it ?
Best Regards, Saludos
Falconi Silvio
Falconi Silvio