Advertisement

10.15.2008 at 12:21PM PDT, ID: 23818011 | Points: 500
[x]
Attachment Details

I need help implementing the following code on C++

Asked by epagos7 in C++ Programming Language, Windows MFC Programming, Windows ATL / WTL / COM Programming

Tags:

Hello,

Im trying to implement a code ive found on MSDN, however i cant get the .GetDocument() member to work on IWebBrowser2 Class.

Ive googled for it and i saw a lot of examples and codes using it without any problem, however im getting the following error:

LPDISPATCH lpDispatch;
SHDocVw::IWebBrowser2^ webbrowser;
lpDispatch = webbrowser->GetDocument();  --> Error show up here

Error      1      error C2039: 'GetDocument' : is not a member of 'SHDocVw::IWebBrowser2'      c:\documents and settings\elias\my documents\visual studio 2008\projects\browser.c++\browser.c++\Form1.h      122      Browser.C++


Source from where i got the code: http://support.microsoft.com/kb/196340
(im pasting it below)

Any help is welcome since im a noob on c++
Thanks.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
// Get the IDispatch of the document
LPDISPATCH lpDisp = NULL;
lpDisp = m_webBrowser.GetDocument();
 
if (lpDisp)
{
   IOleContainer* pContainer;
 
   // Get the container
   HRESULT hr = lpDisp->QueryInterface(IID_IOleContainer,
                                       (void**)&pContainer);
   lpDisp->Release();
 
   if (FAILED(hr))
      return hr;
 
   IEnumUnknown* pEnumerator;
 
   // Get an enumerator for the frames
   hr = pContainer->EnumObjects(OLECONTF_EMBEDDINGS, &pEnumerator);
   pContainer->Release();
 
   if (FAILED(hr))
      return hr;
 
   IUnknown* pUnk;
   ULONG uFetched;
 
   // Enumerate and refresh all the frames
   for (UINT i = 0; S_OK == pEnumerator->Next(1, &pUnk, &uFetched); i++)
   {
      IWebBrowser2* pBrowser;
 
      hr = pUnk->QueryInterface(IID_IWebBrowser2, (void**)&pBrowser);
      pUnk->Release();
 
      if (SUCCEEDED(hr))
      {
         // Refresh the frame
         pBrowser->Refresh();
         pBrowser->Release();
      }
   }
 
   pEnumerator->Release();
}
[+][-]10.15.2008 at 12:56PM PDT, ID: 22725087

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.15.2008 at 01:07PM PDT, ID: 22725239

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.15.2008 at 01:17PM PDT, ID: 22725348

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.16.2008 at 10:42AM PDT, ID: 22733703

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.29.2008 at 12:06PM PDT, ID: 22834484

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628