سؤال

i try to make a basic browser using IWebBrowser2 on dialog based mfc

i insert an active x control into dialog, such as "microsoft web browser"

and i try "AtlAxGetControl" for getting a IWebBrowser2 pointer

but, i always get a e_fail, "res" always fail

void CIWebBrowser2Dlg::OnBnClickedButtonGo() {
CComPtr<IUnknown> punkIE;
CComQIPtr<IWebBrowser2> pWB2;
HWND hWnd;
this->GetDlgItem(IDC_EXPLORER_MAIN, &hWnd);

HRESULT res = AtlAxGetControl(hWnd, &punkIE);
if (res == S_OK) {
    pWB2 = punkIE;
    if(pWB2) {
            pWB2->GoHome();
    }
}
}

i did "AtlAxWinInit();" on initdialog

thank you for reading

plz, let me know how to handle it

هل كانت مفيدة؟

المحلول

Or, why not use the class wizard to generate a wrapper class for you. Then, you won't have to worry about the implementation aspects of the control.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top