Problem getting an ActiveX component to work

HennekensSM
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Problem getting an ActiveX component to work

Post 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)
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

where I can found MapObjects ?
Best Regards, Saludos

Falconi Silvio
HennekensSM
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Post 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
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

can I see a function for delphi to translate in fw ?
you Know all methods of this activex
Best Regards, Saludos

Falconi Silvio
HennekensSM
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Stephan,

Please try this:

hLayers := oMap:GetProp("Layers")

OleInvoke( hLayers, "Add", oLayer )
// oMap:Layers:Add(oLayer)'
regards, saludos

Antonio Linares
www.fivetechsoft.com
HennekensSM
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Post 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
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

I download Lt and install
I compiled your source test
it not found activex
you have the same error ?
Best Regards, Saludos

Falconi Silvio
HennekensSM
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Post by HennekensSM »

No, it does find the ActiveX component. For example CreateObject("MapObjectsLT2.MapLayer") works fine.

Stephan
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post 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 ...
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

Antonio

can you help u please ?
Best Regards, Saludos

Falconi Silvio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Stephan,

What source code line is executing when it GPFs ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post 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)
Best Regards, Saludos

Falconi Silvio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 )
Last edited by Antonio Linares on Mon Jan 29, 2007 1:18 pm, edited 2 times in total.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

Now run ok

Image


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 ?
Best Regards, Saludos

Falconi Silvio
Post Reply