Utilizing Pocket IE Functionality in Mobile Application
IWebBrowser2 interface
For PDA devices running Windows CE.NET (not from Pocket PC family), e.g. Fujitsu iPAD, there is an opportunity to use the IWebBrowser2 interface. That's good news because this interface takes care of a lot of things. If you have used it on a PC, you'll feel pretty comfortable here. A code snippet below shows how to create an instance of IWebBrowser2:
... #include <exdisp.h> // an instance of IWebBrowser2 IWebBrowser2 *m_pBrowserApp; ... void CBrowser::Init(CRect rect,CWnd *pWnd) { //Create the control window if(!CreateControl(CLSID_WebBrowser, NULL, WS_VISIBLE|WS_CHILD, rect,pWnd,AFX_IDW_PANE_FIRST)) { m_pBrowserApp=NULL; DestroyWindow(); } LPUNKNOWN lpUnk = GetControlUnknown(); HRESULT hr = lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp); if(!SUCCEEDED(hr)) { m_pBrowserApp = NULL; DestroyWindow(); } }
With this interface, you get most of a desktop browser's functionality. "Most"—because of regular WinCE restrictions. If you need to capture events from a browser, you may implement the DWebBrowserEvents2 interface. There are a lot of articles on the Web about IWebBrowser-related stuff, so I will not enter into these issues. In any case, you life is easy enough in such an environment.
Conclusions
Using either HTML Control or IWebBrowser2, you may make your applications much more powerful and attracive. Have fun!
About the Author
Alex Gusev started to play with mainframes at the end of the 1980s, using Pascal and REXX, but soon switched to C/C++ and Java on different platforms. When mobile PDAs seriously rose their heads in the IT market, Alex did it too. Now, he works at an international retail software company as a team leader of the Mobile R department, making programmers' lives in the mobile jungles a little bit simpler.
Page 2 of 2
This article was originally published on March 23, 2004