Controlling an instance of PIE

This forum contains short topics that require short answers. Developers arround the world are welcomed to help the community, or to post their own questions.
[C++ development]

Moderators: Teksoft, admin

Controlling an instance of PIE

Postby Geoff » Wed Sep 27, 2006 12:43 pm

I'm trying to start an instance of Pocket Internet Explorer and navigate to a webite on a PocketPC running Windows Mobile 5. The code compiles, links and runs OK but nothing seems to happen on the display.

Can anyone see what's wrong with this code....

HRESULT hr;

hr = CoInitializeEx (NULL, COINIT_MULTITHREADED);

if (hr == S_OK) {
hr = CoCreateInstance (CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (LPVOID *)&m_pBrowser);
if (hr == S_OK) {
// make the browser visible
VARIANT_BOOL pBool=true;
m_pBrowser->put_Visible(pBool);

COleVariant vaURL(_T("http://www.hotmail.com")) ;
COleVariant null;
m_pBrowser->Navigate2(vaURL,null,null,null,null) ;
}
}

Thanks.
Geoff
TEK-Seeker
 
Posts: 22
Joined: Fri May 05, 2006 12:45 pm

Postby sad_ghost » Wed Sep 27, 2006 10:02 pm

Here is a sample paste from the PB:

HWND CMainWnd::CreateBrowser()
{
HRESULT hr;
IUnknown *pUnk = NULL;
IOleObject *pObject = NULL;


if (!_pBrowser)
{
GetProxyOption();
hr = CoCreateInstance(CLSID_WebBrowser, NULL,
CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
IID_IUnknown, (LPVOID *)(&pUnk));
if (FAILED(hr))
return FALSE;

hr = pUnk->QueryInterface(IID_IOleObject, (LPVOID *)(&pObject));
if (FAILED(hr))
goto Cleanup;

DWORD dwFlags;
hr = pObject->GetMiscStatus(DVASPECT_CONTENT, &dwFlags);
if (FAILED(hr))
goto Cleanup;

if (dwFlags & OLEMISC_SETCLIENTSITEFIRST)
{
IOleClientSite *pClientSite;
hr = QueryInterface(IID_IOleClientSite, (LPVOID *)(&pClientSite));
if (FAILED(hr))
goto Cleanup;

hr = pObject->SetClientSite(pClientSite);
pClientSite->Release();
if (FAILED(hr))
goto Cleanup;
}

hr = Activate(pObject);
if (FAILED(hr))
goto Cleanup;

hr = _pObject->QueryInterface(IID_IWebBrowser2, (void **)&_pBrowser);
if (FAILED(hr))
goto Cleanup;

// See if there might be a url in lpszUrl
hr = pUnk->QueryInterface(IID_IOleInPlaceActiveObject, (LPVOID *)(&_pIPActiveObj));
if (FAILED(hr))
_pIPActiveObj = NULL;

hr = S_FALSE;

if (_fEmpty)
{

BSTR bstrURL = SysAllocString(_lpszUrl);
if (bstrURL && bstrURL[0])
_pBrowser->Navigate(bstrURL, NULL, NULL, NULL, NULL);
else
_pBrowser->GoHome();

SysFreeString(bstrURL);

}
hr = InitEvents();
}

Cleanup:
if (pUnk)
pUnk->Release();
if (pObject)
pObject->Release();

IOleWindow *pWnd = NULL;
HWND hwndBrowser = NULL;

if (_pBrowser)
{
hr = _pBrowser->QueryInterface(IID_IOleWindow, (LPVOID *)(&pWnd));
if (FAILED(hr))
return NULL;
}

if (pWnd)
{
hr = pWnd->GetWindow(&hwndBrowser);
pWnd->Release();
}
return hwndBrowser;
}

You can take a look at the Platform Builder sample related to Internet Explorer for more infos.

Cheers,
Raul
sad_ghost
TEK-Giant
TEK-Giant
 
Posts: 269
Joined: Thu Apr 06, 2006 11:04 am

Postby Geoff » Fri Sep 29, 2006 10:34 am

Hmmm, so it's not as easy as the version for the desktop that I was merely hacking to work on PocketPC?

I've looked at a number of different examples of something similar to what I want to achieve, but they all seem to be different. :?
Geoff
TEK-Seeker
 
Posts: 22
Joined: Fri May 05, 2006 12:45 pm


Return to Pocketpc

Who is online

Users browsing this forum: No registered users and 0 guests


cron