Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. How to get Interface to Control after #importing

How to get Interface to Control after #importing

Scheduled Pinned Locked Moved COM
helptutorialcomquestion
4 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JohnnyG
    wrote on last edited by
    #1

    I'm using VC6 and the MapWindowGIS control, MapWindowGIS.OCX. It has many interfaces but few examples on how to use it using VC6. I'm kind of new to using COM so my terminology is probably incorrect to some degree. The problem is I can get to one of the interfaces, IShapeFile, using their example using:

    IShapefilePtr* pShapeFile = new IShapefilePtr;

    HRESULT hr = pShapeFile->CreateInstance(__uuidof(Shapefile));

    CreateInstance(), but when I try this on other interfaces such as IGrid and IGridHeader, CreateInstance() fails with the "Class Not Registered" error (0x80040154). Since, the control, MapWindowGIS.OCX is registered, and I was able to get the IShapeFile interface, I'm assuming that I need to call QueryInterface() but the IGrid and IGridHeader interfaces are not part of the IShapeFile interface. So, I'm assuming then I need to get a pointer to the MapWindowGIS control but I'm not instantiating it directly since it is #import(ed). VC6 created the .tli and tlh files and a CWnd derived class from the OCX called, CMap1. Is there something I can call in CMap1 that will return the main object's interface pointer so I can then call QueryInterface()?

    J 1 Reply Last reply
    0
    • J JohnnyG

      I'm using VC6 and the MapWindowGIS control, MapWindowGIS.OCX. It has many interfaces but few examples on how to use it using VC6. I'm kind of new to using COM so my terminology is probably incorrect to some degree. The problem is I can get to one of the interfaces, IShapeFile, using their example using:

      IShapefilePtr* pShapeFile = new IShapefilePtr;

      HRESULT hr = pShapeFile->CreateInstance(__uuidof(Shapefile));

      CreateInstance(), but when I try this on other interfaces such as IGrid and IGridHeader, CreateInstance() fails with the "Class Not Registered" error (0x80040154). Since, the control, MapWindowGIS.OCX is registered, and I was able to get the IShapeFile interface, I'm assuming that I need to call QueryInterface() but the IGrid and IGridHeader interfaces are not part of the IShapeFile interface. So, I'm assuming then I need to get a pointer to the MapWindowGIS control but I'm not instantiating it directly since it is #import(ed). VC6 created the .tli and tlh files and a CWnd derived class from the OCX called, CMap1. Is there something I can call in CMap1 that will return the main object's interface pointer so I can then call QueryInterface()?

      J Offline
      J Offline
      Jonathan Davies
      wrote on last edited by
      #2

      JohnnyG wrote:

      I was able to get the IShapeFile interface, I'm assuming that I need to call QueryInterface() but the IGrid and IGridHeader interfaces are not part of the IShapeFile interface

      No, but you normally would get, say, an IGridHeader interface by using the IShapeFile interfaces method QueryInterface asking it for an IGridHeader interface. All interfaces inherit from the base interface IUnknown which has three methods, QueryInterface being one of them. Having got one interface you can then use its QueryInterface method to get another interface implemented by the object.

      J 1 Reply Last reply
      0
      • J Jonathan Davies

        JohnnyG wrote:

        I was able to get the IShapeFile interface, I'm assuming that I need to call QueryInterface() but the IGrid and IGridHeader interfaces are not part of the IShapeFile interface

        No, but you normally would get, say, an IGridHeader interface by using the IShapeFile interfaces method QueryInterface asking it for an IGridHeader interface. All interfaces inherit from the base interface IUnknown which has three methods, QueryInterface being one of them. Having got one interface you can then use its QueryInterface method to get another interface implemented by the object.

        J Offline
        J Offline
        JohnnyG
        wrote on last edited by
        #3

        Well, I'm kind of at a loss because I tried that with the IShapeFile interface (meaning I called QueryInterface for the IGrid interface on the IShapeFile interface) and I'm getting the E_NOINTERFACE error. That is why I was asking about how I get a interface pointer from the OCX control itself. All of the examples are for VS 2008 in C# and VB.net. The only example they provide for VC6 is for creating a map using a shapefile hence, the IShapeFile interface. I have the CLSID for the OCX is there some way I can get its main interface or IUnknown interface from the OCX using this CLSID ??

        modified on Monday, April 26, 2010 5:19 PM

        J 1 Reply Last reply
        0
        • J JohnnyG

          Well, I'm kind of at a loss because I tried that with the IShapeFile interface (meaning I called QueryInterface for the IGrid interface on the IShapeFile interface) and I'm getting the E_NOINTERFACE error. That is why I was asking about how I get a interface pointer from the OCX control itself. All of the examples are for VS 2008 in C# and VB.net. The only example they provide for VC6 is for creating a map using a shapefile hence, the IShapeFile interface. I have the CLSID for the OCX is there some way I can get its main interface or IUnknown interface from the OCX using this CLSID ??

          modified on Monday, April 26, 2010 5:19 PM

          J Offline
          J Offline
          Jonathan Davies
          wrote on last edited by
          #4

          A search took me to the Mapwindow Wiki [^] where it says "An ESRI grid manager object provides functions which facilitate using ESRI grids with MapWinGIS". So it sounds to me as if you should be looking to work with the GridManager before trying to get an IGrid or IGridHeader.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups