Como usar GetDHtmlDocument () na programação MFC?
Estou tentando usar
HRESULT GetDHtmlDocument (IHTMLDocument2 ** pphtmlDoc);
unção na programação MF
Basicamente, estou tentando renderizar a GUI em um aplicativo de diálogo de exibição HTML (C ++ w / MFC), com uma configuração diferente (carregamento de entrada
Então eu coloquei o seguinte código em uma função OnInitDialog (
BOOL CSampleProgramDlg::OnInitDialog()
{
CDHtmlDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
// My code starts from here....
HRESULT hr = S_OK;
IHTMLDocument2 *pphtmlDoc;
//MessageBox(_T("If I let this MessageBox to pop-up, the code works fine."));
hr = GetDHtmlDocument(&pphtmlDoc);
IHTMLElement *e;
hr = GetElement(_T("someElement"), &e);
if (SUCCEEDED(hr))
e->put_innerHTML(_T("<h1>someLoadingInputWillGoHereLater</h1>"));
//My code ends here.....
return TRUE;
}
Como comentei no código acima, se eu permitir que o Messagebox pop-up o elemento com ID = "someElement" imprima "someLoadingInputWillGoHereLater".
Mas se eu comentar o Messagebox, GetDHtmlDocument () retornará "E_NOINTERFACE" HRESULT e fará com que o código não funcion
Só posso adivinhar que talvez seja o problema do "foco". Mas não consigo descobrir a causa exat
Então peço sua ajuda. =