Hi,
I'm trying my hand at COM programming. The examples seem to work fine, but I'm having a little trouble with Property Get statements in the real world.
I am trying to open (and see some properties of) an ESRI ShapeFile using the OCX provided by the OpenSource MapWindow project. The COM browser looked it over, liked it, and generated a .INC file for the OCX.
The following is an excerpt from the .INC file:
I was overjoyed when the "OPEN" method worked in my little piece of code that follows. Then, I wanted to view one of the properties of the shapefile. I must have missed something because the "ShapeCount =" line near the end of the code below returns an error at the .ShapeCount item saying that a method or property is expected.
I'm sure I am missing something, but at this point, I can't figure out what it might be...
Some helpful comments would sure be appreciated!
Ken
I'm trying my hand at COM programming. The examples seem to work fine, but I'm having a little trouble with Property Get statements in the real world.
I am trying to open (and see some properties of) an ESRI ShapeFile using the OCX provided by the OpenSource MapWindow project. The COM browser looked it over, liked it, and generated a .INC file for the OCX.
The following is an excerpt from the .INC file:
Code:
INTERFACE IShapefile $IID_MapWinGIS_IShapefile INHERIT IDISPATCH PROPERTY GET NumShapes <1> () AS LONG PROPERTY GET NumFields <2> () AS LONG PROPERTY GET Extents <3> () AS IExtents PROPERTY GET ShapefileType <4> () AS LONG PROPERTY GET Shape <5> (BYVAL ShapeIndex AS LONG) AS IShape PROPERTY GET EditingShapes <6> () AS INTEGER PROPERTY GET LastErrorCode <7> () AS LONG PROPERTY GET CdlgFilter <8> () AS STRING PROPERTY GET GlobalCallback <9> () AS ICallback PROPERTY SET GlobalCallback <9> (BYVAL pVal AS ICallback) PROPERTY GET Key <10> () AS STRING PROPERTY SET Key <10> (BYVAL pVal AS STRING) METHOD OPEN <11> (BYVAL ShapefileName AS STRING, OPT BYVAL cBack AS ICallback) AS INTEGER METHOD CreateNew <12> (BYVAL ShapefileName AS STRING, BYVAL ShapefileType AS LONG) AS INTEGER METHOD SaveAs <13> (BYVAL ShapefileName AS STRING, OPT BYVAL cBack AS ICallback) AS INTEGER METHOD CLOSE <14> () AS INTEGER
Code:
#COMPILE EXE #DIM ALL #INCLUDE "MapWinInc.inc" GLOBAL ShapeName AS STRING DECLARE FUNCTION OpenShp() AS INTEGER FUNCTION PBMAIN () AS LONG 'MSGBOX "Got Here" IF COMMAND$ = "" THEN shapename = "c:\newmaps\B-L Little 08 Harvest.shp" ELSE ShapeName = COMMAND$ END IF openshape END FUNCTION FUNCTION OpenShape() AS INTEGER LOCAL DispVar AS DISPATCH LOCAL ShapeCount AS LONG LOCAL mShapeCallBack AS ICallBack LET DispVar = NEWCOM "IShapefile" OBJECT CALL DispVar.open(ShapeName, mShapeCallBack) ShapeCount = DispVar.ShapeCount 'Error shows up in this line FUNCTION = 1 END FUNCTION
Some helpful comments would sure be appreciated!
Ken
Comment