Lm th? no ? c ?c m h?nh ?i t?ng WebBrowser m?t khung HTML

D?ch tiu ? D?ch tiu ?
ID c?a bi: 196340
(c) t?p on Microsoft 1998, t?t c? cc quy?n. Nh?ng ng gp c?a Scott Roberts, t?p on Microsoft.
Bung t?t c? | Thu g?n t?t c?

TM T?T

C th? cc my ch? i?u khi?n k? thu?t tiu chu?n WebBrowser chi ti?t bi vi?t ny s? d?ng ? truy c?p vo cc m h?nh ?i t?ng WebBrowser c?a khung c?a s? trong m?t trang HTML bn trong s? ki?m sot. M h?nh ?i t?ng ny cung c?p thm ch?c nng m l khng ?c ti?p xc cho khung c?a s? thng qua m h?nh ?i t?ng HTML.

THNG TIN THM

M? sau y ch?ng t? lm th? no ? truy c?p vo cc m h?nh ?i t?ng WebBrowser khung trong m?t trang HTML ? lm m?i n?i dung c?a m?i khung.

Ph?n quan tr?ng nh?t c?a m? s? d?ng IOleContainer::EnumObjects phng th?c c?a ?i t?ng ti li?u HTML li?t k embeddings trn trang. M?i ng?i trong s? nh?ng embeddings ?i di?n cho m?t i?u khi?n trn trang. B?i cu m?i ki?m sot ?i t?ng cho IWebBrowser2, m? ny c th? xc ?nh xem cc ki?m sot l m?t sub-frame. V IWebBrowser2 ?i di?n cho cc ?i t?ng WebBrowser M h?nh; N?u QueryInterface thnh cng cho giao di?n ny, k?t qu? l m?t ti li?u tham kh?o ? WebBrowser Object Model.
// 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();
}
Chu y i?u khi?n ActiveX ?c lu tr? trong m?t trang HTML c th? s? d?ng k? thu?t ny trong m?t cch tng t?. Ni chung, m?t i?u khi?n ActiveX ch? y?u truy c?p cc khng an ton WebBrowser Object Model l khng an ton cho k?ch b?n v nn th?c hi?n IObjectSafety giao di?n cho ph h?p ? b?o m?t.

Thu?c tnh

ID c?a bi: 196340 - L?n xem xt sau cng: 20 Thang Tam 2011 - Xem xt l?i: 2.0
T? kha:
kbfaq kbhowto kbwebbrowser kbmt KB196340 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny:196340
Khc t Ni dung trong C s Kin thc Khng con c h tr
Bi vi?t ny ni v? cc s?n ph?m m Microsoft khng c?n h? tr? n?a. Do , bi vi?t ny ?c cung c?p "nguyn b?n" v s? khng ?c c?p nh?t.

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com