Champa
01-30-2007, 08:42 AM
hi,
I need to retrieve the html content of a particular page by creating a
BHO.
I am able to do this for a desktop application.
But my necessity is Windows Mobile 5.0 Pocket PC.
************************************************** *********************
#include <mshtml.h>
hr = m_spWebBrowser->get_Document(&spDispDoc);
if (SUCCEEDED(hr))
{
CComPtr<IDispatch> spDispDoc;
// ...and query for an HTML document.
//CComQIPtr<IHTMLDocument2> spHTMLDoc = spDispDoc;
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML;
spHTML = spDispDoc;
if ( spHTML )
{
CComPtr<IHTMLElement> m_pBody;
hr = spHTML->get_body(&m_pBody);
BSTR bstrHTMLText;
hr = m_pBody->get_outerHTML(&bstrHTMLText);
MessageBox( NULL, bstrHTMLText, L"Hello", NULL );
}
************************************************** *********************
******
I have used mshtml.h for using these functiions. But this .h and its
lib is not available in our Windows Mobile Pocket PC 5.0.
How to achieve this ?
*** i tried using the same .h and lib for Pocket PC that is given for
desktop . But i am having issues in it.
Can anyone help me out ?
Thank you,
Champa
Randy Ramig (MSFT)
01-30-2007, 09:31 PM
You can't use mshtml.h on Windows Mobile-- it should have never been in the
SDK. Use webvw.h and IPIEHTMLDocument2.
"Champa" wrote:
> hi,
>
> I need to retrieve the html content of a particular page by creating a
> BHO.
> I am able to do this for a desktop application.
> But my necessity is Windows Mobile 5.0 Pocket PC.
> ************************************************** *********************
> #include <mshtml.h>
>
> hr = m_spWebBrowser->get_Document(&spDispDoc);
>
> if (SUCCEEDED(hr))
> {
> CComPtr<IDispatch> spDispDoc;
> // ...and query for an HTML document.
> //CComQIPtr<IHTMLDocument2> spHTMLDoc = spDispDoc;
>
> CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spHTML;
> spHTML = spDispDoc;
>
> if ( spHTML )
> {
> CComPtr<IHTMLElement> m_pBody;
> hr = spHTML->get_body(&m_pBody);
>
> BSTR bstrHTMLText;
> hr = m_pBody->get_outerHTML(&bstrHTMLText);
>
> MessageBox( NULL, bstrHTMLText, L"Hello", NULL );
> }
> ************************************************** *********************
> ******
> I have used mshtml.h for using these functiions. But this .h and its
> lib is not available in our Windows Mobile Pocket PC 5.0.
> How to achieve this ?
>
> *** i tried using the same .h and lib for Pocket PC that is given for
> desktop . But i am having issues in it.
>
> Can anyone help me out ?
>
> Thank you,
> Champa
>
>
Champa
02-02-2007, 01:48 AM
hi,
Thanks a lot.When i used webvw.h , i could create IPIEHMLDocument2.
But
I am trying to retrieve the html page of a particular url on WIndow
Mobile 5.0.
I am able to get the number of links on a page, value of each link,
url of that page etc.
But i want the entire html page.
My code which does watever i have mentioned above is as shown.
/
************************************************** ************************************************** ****/
void __stdcall CIEHlprObj::OnDocumentComplete(IDispatch * pDisp,
VARIANT * pvtURL)
{
HRESULT hr;
// Query for the IWebBrowser2 interface.
CComQIPtr<IWebBrowser2> spTempWebBrowser = pDisp;
// Is this event associated with the top-level browser?
if (spTempWebBrowser && m_spWebBrowser2 &&
m_spWebBrowser2.IsEqualObject(spTempWebBrowser))
{
// Get the current document object from browser...
CComPtr<IDispatch> spDispDoc;
hr = m_spWebBrowser2->get_Document(&spDispDoc);
if ( SUCCEEDED( hr ) )
{
// ...and query for an HTML document.
CComQIPtr<IPIEHTMLDocument2> spHTMLDoc = spDispDoc;
CComQIPtr<IPIEHTMLDocument2, &IID_IPIEHTMLDocument2>
spHTML;
spHTML = spDispDoc;
if ( spHTML )
{
BSTR bstrDomain;
// This is one funtion
hr = spHTML->get_domain( &bstrDomain );
// This is one funtion
hr = spHTML->get_URL( &bstrDomain );
MessageBox( NULL, bstrDomain, L"Name", NULL );
IPIEHTMLElementCollection *pElementCollection = NULL;
// This is one funtion ( working )
//hr = spHTML->get_links( &pElementCollection );
// This is one funtion ( working)
hr = spHTML->get_forms( &pElementCollection );
if ( SUCCEEDED( hr ) )
{
long items;
WCHAR szItem[200];
// This is one funtion ( working)
pElementCollection->get_length( &items );
_stprintf( szItem, L"%d", items );
MessageBox( NULL, szItem, L"Item", NULL );
for ( int i = 0; i < items; i++ )
{
VARIANT vtIndex;
vtIndex.vt = VT_UINT;
vtIndex.lVal = i;
VARIANT var2;
VariantInit( &var2 );
IDispatch* pItem = NULL;
if( pElementCollection->item( vtIndex, var2,
(IDispatch**)&pItem ) == S_OK )
{
//MessageBox( NULL, L"Champa", L"href -->
%s", NULL );
IPIEHTMLAnchorElement* pAnchor = NULL;
if( pItem->QueryInterface(
__uuidof(IPIEHTMLAnchorElement), (void
**)&pAnchor ) == S_OK )
{
BSTR bstrName;
if( pAnchor->get_href( &bstrName ) ==
S_OK )
{
MessageBox( NULL, bstrName,
L"href
--> %s", NULL );
SysFreeString( bstrName );
}
}
}
}
}
}
}
}
/
************************************************** ************************************************** **/
Can anyone tell me how to retrieve the whole page.
For Desktop it has a get_body function which retrieves the page.
But for Windows Mobile 5.0,
I didnt find it..
Do the needful
Thanks,
Champa