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 execute methods from ATL/COM base class

How to execute methods from ATL/COM base class

Scheduled Pinned Locked Moved COM
c++comdockerhelptutorial
5 Posts 3 Posters 0 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.
  • D Offline
    D Offline
    Doug Knudson
    wrote on last edited by
    #1

    In VS6 C++, I have a windowless ATL control. To get a Device Context from the container, I belive I need to execute the GetDC() method of one of the base classes for the control, specifically IOleInPlaceObjectWindowless. I tried to do this: CDC *pDC = IOleInPlaceObjectWindowless::GetDC(); But it doesn't work so I am at a loss as to how to execute a method on the IOleInPlaceObjectWindowless interface. Any help would be greatly appreciated, Thanks, Doug

    Doug Knudson

    P M 2 Replies Last reply
    0
    • D Doug Knudson

      In VS6 C++, I have a windowless ATL control. To get a Device Context from the container, I belive I need to execute the GetDC() method of one of the base classes for the control, specifically IOleInPlaceObjectWindowless. I tried to do this: CDC *pDC = IOleInPlaceObjectWindowless::GetDC(); But it doesn't work so I am at a loss as to how to execute a method on the IOleInPlaceObjectWindowless interface. Any help would be greatly appreciated, Thanks, Doug

      Doug Knudson

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      You can use methods exposed by interfaces ,only. Or you want to say smething else ?

      D 1 Reply Last reply
      0
      • P prasad_som

        You can use methods exposed by interfaces ,only. Or you want to say smething else ?

        D Offline
        D Offline
        Doug Knudson
        wrote on last edited by
        #3

        Thanks for the reply. I didn't ask my question very well, but basically I am writing a windowless ATL component and need the Device Context from the Parent/Container so that I may draw in event handlers (for example, in MouseMove()). During my length time searching, all I could find was people saying that I needed to just execute the GetDC() method of the IOleInPlaceObjectWindowless interface like this:

        HDC hDC = NULL;
        HRESULT hr = IOleInPlaceObjectWindowless::GetDC(myRect,myFlags,&hDC);

        The compiler interprets the above as trying to execute a static member function, which, of course, GetDC() isn't. If I just use:

        GetDC();

        I get the API GetDC() that expects there to be a m_hWnd, which there isn't (windowless control), so I am pretty lost as to how to do this. Thanks, Doug

        Doug Knudson

        1 Reply Last reply
        0
        • D Doug Knudson

          In VS6 C++, I have a windowless ATL control. To get a Device Context from the container, I belive I need to execute the GetDC() method of one of the base classes for the control, specifically IOleInPlaceObjectWindowless. I tried to do this: CDC *pDC = IOleInPlaceObjectWindowless::GetDC(); But it doesn't work so I am at a loss as to how to execute a method on the IOleInPlaceObjectWindowless interface. Any help would be greatly appreciated, Thanks, Doug

          Doug Knudson

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          There is no GetDC method on the IOleInPlaceObjectWindowless interface, nor any of its base interfaces. You should generally be doing all your drawing in your implementation of IViewObject::Draw, i.e. in OnDraw. If you need to do some drawing outside of this, the GetDC call is on IOleInPlace_Site_Windowless, which you have to ask the container for. I believe you should call InternalGetSite (which is inherited from CComControlBase) to retrieve a pointer to this interface.

          "Multithreading is just one damn thing after, before, or simultaneous with another." - Andrei Alexandrescu

          D 1 Reply Last reply
          0
          • M Mike Dimmick

            There is no GetDC method on the IOleInPlaceObjectWindowless interface, nor any of its base interfaces. You should generally be doing all your drawing in your implementation of IViewObject::Draw, i.e. in OnDraw. If you need to do some drawing outside of this, the GetDC call is on IOleInPlace_Site_Windowless, which you have to ask the container for. I believe you should call InternalGetSite (which is inherited from CComControlBase) to retrieve a pointer to this interface.

            "Multithreading is just one damn thing after, before, or simultaneous with another." - Andrei Alexandrescu

            D Offline
            D Offline
            Doug Knudson
            wrote on last edited by
            #5

            Hi Mike, Thanks! I will give that a try. I am doing the bulk of my drawing in OnDraw() but I need to drag a selection rectangle during the MouseDown, MouseMove, MouseUp events so I need to (or at least I think I need to :)) have the DC outside of what is handed to me in OnDraw() ?? Thanks again, Doug

            Doug Knudson

            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