Problem getting an ActiveX component to work

Problem getting an ActiveX component to work

Postby HennekensSM » Sun Jan 28, 2007 9:54 pm

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)
HennekensSM
 
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Postby Silvio » Sun Jan 28, 2007 10:54 pm

where I can found MapObjects ?
Best Regards, Saludos

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

Postby HennekensSM » Sun Jan 28, 2007 11:03 pm

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
HennekensSM
 
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Postby Silvio » Mon Jan 29, 2007 9:59 am

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

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

Postby HennekensSM » Mon Jan 29, 2007 10:05 am

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
HennekensSM
 
Posts: 17
Joined: Sun Jan 28, 2007 11:47 am

Postby Antonio Linares » Mon Jan 29, 2007 10:29 am

Stephan,

Please try this:

hLayers := oMap:GetProp("Layers")

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HennekensSM » Mon Jan 29, 2007 10:39 am

Antonio,

I thing we made a step forward, but it's GPF's before showing the map. Scrollbars however already appear.

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

Postby Silvio » Mon Jan 29, 2007 10:42 am

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

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

Postby HennekensSM » Mon Jan 29, 2007 10:59 am

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

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

Postby Silvio » Mon Jan 29, 2007 11:37 am

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

Postby Silvio » Mon Jan 29, 2007 12:10 pm

Antonio

can you help u please ?
Best Regards, Saludos

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

Postby Antonio Linares » Mon Jan 29, 2007 12:26 pm

Stephan,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Silvio » Mon Jan 29, 2007 12:53 pm

it not run DO method

Code: Select all  Expand view

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

Postby Antonio Linares » Mon Jan 29, 2007 1:15 pm

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

Postby Silvio » Mon Jan 29, 2007 1:15 pm

Now run ok

Image



Code: Select all  Expand view
#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
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests