Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get HWND of a windowless ATL control?
    primarykey
    data
    text
    <p>I created a ATL windows less control and the class definition is like this:</p> <pre><code> class ATL_NO_VTABLE CRSPClient : public IObjectSafetyImpl&lt;CRSPClient, INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA&gt;, public CComObjectRootEx&lt;CComSingleThreadModel&gt;, public IDispatchImpl&lt;IRSPClient, &amp;IID_IRSPClient, &amp;LIBID_axBanckleRSPClientLib, /*wMajor =*/ 1, /*wMinor =*/ 0&gt;, public IPersistStreamInitImpl&lt;CRSPClient&gt;, public IOleControlImpl&lt;CRSPClient&gt;, public IOleObjectImpl&lt;CRSPClient&gt;, public IOleInPlaceActiveObjectImpl&lt;CRSPClient&gt;, public IQuickActivateImpl&lt;CRSPClient&gt;, public IViewObjectExImpl&lt;CRSPClient&gt;, public IOleInPlaceObjectWindowlessImpl&lt;CRSPClient&gt;, #ifdef _WIN32_WCE // IObjectSafety is required on Windows CE for the control to be loaded correctly public IObjectSafetyImpl&lt;CRSPClient, INTERFACESAFE_FOR_UNTRUSTED_CALLER&gt;, #endif public CComCoClass&lt;CRSPClient, &amp;CLSID_RSPClient&gt;, public CComControl&lt;CRSPClient&gt; </code></pre> <p>Then for some purpose I need to post message to the window. I tried to get the handle of the window in quite many ways and ALL of them failed:</p> <pre><code> HWND CRSPClient::GetHwnd() { HWND hwndRet = NULL; // hwndRet = m_hWnd; //IOleInPlaceActiveObjectImpl&lt;CRSPClient&gt;::GetWindow(&amp;hwndRet); //IOleWindow&lt;CRSPClient&gt;::GetWindow(&amp;hwndRet); //this-&gt;m_spInPlaceSite-&gt;GetWindow(&amp;hwndRet); //CComQIPtr&lt;IOleInPlaceSite&gt; spSite = this-&gt;m_spClientSite; //spSite-&gt;GetWindow(&amp;hwndRet); //hwndRet = ::WindowFromDC(GetDC()); return hwndRet; } </code></pre> <p>Anybody know be there any way to get the HWND?</p> <p>OMG I'm totally frustrated by microsoft's great ATL framework!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload