我正在尝试使用以下类构建一个新窗口。但是我在尝试使用 CWindow::m_hwnd 变量获取新生成的窗口名称时遇到了一些严重的问题。我的猜测是我应该将一个变量传递给包含我父母的 HWND 的 CWindowImpl::Create() 函数,但我不知道如何获取它。
STDMETHODIMP CVMNExporter::SetSite(IUnknown *pUnkSite) {
HRESULT hr;
if(FAILED(hr = ATL::IObjectWithSiteImpl<CVMNExporter>::SetSite(pUnkSite)))
return hr;
// We are rnning from a web browser
CONNECTION_CALLBACK = JSCRIPT_DISPID;
EXPORTING_CALLBACK = JSCRIPT_DISPID;
MERGING_CALLBACK = JSCRIPT_DISPID;
ABORTING_CALLBACK = JSCRIPT_DISPID;
AddRef();
if(NULL == Create(0)) {// Creates the hidden window
Release();
return HRESULT_FROM_WIN32(GetLastError());
}
ATLTRACE("TEST - SetSite(): this: %d, window: %d", this, m_hWnd);
m_dwApartmentMode = HWND_APARTMENT;
SendMessage(WM_EXPORTER_APARTMENT_SETUP, 0, 0);
return S_OK; }
CVMNExporter 实现以下接口:
public ATL::IObjectSafetyImpl<CVMNExporter, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,
public ATL::IObjectWithSiteImpl<CVMNExporter>,
public ATL::CWindowImpl<CVMNExporter, ATL::CWindow, ATL::CFrameWinTraits>,
谢谢!