1

im trying to build a new window using the following class. however im having some serious problems while trying to get the new generated window's name using the CWindow::m_hwnd variable. my guess is that i should pass a variable to the CWindowImpl::Create() function that holds my parent's HWND but i dont know how to get it.

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 implements the following interfaces:

        public ATL::IObjectSafetyImpl<CVMNExporter, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,
        public ATL::IObjectWithSiteImpl<CVMNExporter>,
        public ATL::CWindowImpl<CVMNExporter, ATL::CWindow, ATL::CFrameWinTraits>,

thanks!

1
  • CWindowImpl::Create creates you the window and you are going to have your HWND available since there. If you want to provide parent window handle, you need to first obtain it from your site. You will need to query it using IOleWindow::GetWindow or similar method. Commented May 6, 2012 at 9:14

1 Answer 1

1

Well it took me some time, but managed to solve it by using GetActiveWindow()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.