How to execute methods from ATL/COM base class
-
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
-
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
You can use methods exposed by interfaces ,only. Or you want to say smething else ?
-
You can use methods exposed by interfaces ,only. Or you want to say smething else ?
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
-
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
There is no
GetDC
method on theIOleInPlaceObjectWindowless
interface, nor any of its base interfaces. You should generally be doing all your drawing in your implementation ofIViewObject::Draw
, i.e. inOnDraw
. If you need to do some drawing outside of this, theGetDC
call is on IOleInPlace_Site_Windowless, which you have to ask the container for. I believe you should callInternalGetSite
(which is inherited fromCComControlBase
) to retrieve a pointer to this interface."Multithreading is just one damn thing after, before, or simultaneous with another." - Andrei Alexandrescu
-
There is no
GetDC
method on theIOleInPlaceObjectWindowless
interface, nor any of its base interfaces. You should generally be doing all your drawing in your implementation ofIViewObject::Draw
, i.e. inOnDraw
. If you need to do some drawing outside of this, theGetDC
call is on IOleInPlace_Site_Windowless, which you have to ask the container for. I believe you should callInternalGetSite
(which is inherited fromCComControlBase
) to retrieve a pointer to this interface."Multithreading is just one damn thing after, before, or simultaneous with another." - Andrei Alexandrescu
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