Partager via


Windows Mobile 6.5 Web Browser Control: Enabling Gesture support

One of the most powerful controls in the Windows Mobile developer toolbox is the Web Browser control. With this control, you can create applications as simple as displaying HTML, to more complex apps that interact with the DOM manipulating elements, and fining / responding to events.

The introduction of touch and gesture support in Windows Mobile 6.5 has greatly improved the user experience. You can now intuitively flick and pan with your finger in most of the Microsoft applications and your own! Adding gesture support to your application is not trivial. See the Windows Mobile 6.5 Developer Tool Kit (DTK) for more information.  Fortunately Microsoft has included gesture support in the Web Browser control for 6.5

There are actually two web browsers in Windows Mobile 6.5. One that is used by Internet Explorer Mobile and another that is used by applications hosting the Web Browser control. This post will focus on the later.

There are two ways to instantiate the web browser control. The first method uses a COM interface to create the control. (See the miniPie SDK sample.) The second method hosts the control as a child of a DISPLAYCLASS window (The docs refer to this as the ‘HTML control’). In order to create this control with gesture support, you create it with the HS_NOSELECTION flag. For example:

 hWndHtml = CreateWindow(TEXT("DISPLAYCLASS"), NULL,
         WS_VISIBLE | HS_NOSELECTION,0 , 0, GetSystemMetrics(SM_CXSCREEN),
         GetSystemMetrics(SM_CYSCREEN), hWnd, NULL, g_hInst, NULL);

You can see this for yourself:

  1. Open the Browse SDK sample
  2. Add the HS_NOSELECTION flag (as shown above) to the DISPLAYCLASS CreateWindow call
  3. Build and Run

In the video below, I changed the sample to load an HTML file that contained more than a screen full of data in order to force scrolling so that you can see the navigation via gestures (Flick and Pan):

Additional Resources:

Note that the information above is not documented by Microsoft and is therefore not supported.

del.icio.us Tags: gestures,windowsmobile,6.5

Comments

  • Anonymous
    July 22, 2009
    Do you know any way to do this in managed code on a Windows Mobile 6.5 device/emulator? If i use the WebBrowser-control in my .NETCF 3.5 app on a 6.5 device/emulator i get very strange looking html. The text is too big and i cannot scroll at all (not by finger and there are no scrollbars).

  • Anonymous
    September 03, 2009
    Hmm... how easy would it be to wrap this for managed code? The current webbrowser control in wm 6.5 is badly broke, with no scrollbars or gestures.

  • Anonymous
    October 01, 2009
    There is no way to get to the dispatch interface using the .Net Compact Framework so you can't use this method to disable / enable selection. Regarding using .Net CF 3.5 and the Web Browser control, there is a fix now available for this. See here for more information: KB Article: http://support.microsoft.com/kb/975281 http://blogs.msdn.com/raffael/archive/2009/09/29/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-6-1-4-onwards-to-address-basic-functionalities-of-webbrowser-control.aspx

  • Anonymous
    November 04, 2009
    Is there a way to enable Gesture Scroll on MiniPIE sample?

  • Anonymous
    November 05, 2009
    Hi Mohan, I have not tested this, but this should work. See the article here http://bit.ly/Z5k7q on enabling selection support. When selection mode is off, gesture mode will be on. You need access to the IBrowser3 interface, you can QI from the dispatch interface to get it. Mike

  • Anonymous
    November 06, 2009
    Hi Mike, IBrowser3 is no longer supported in WM... is that true? http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/c9c60996-7a7d-465d-9608-af5edbd77cb4/ Thanks, Mohan

  • Anonymous
    November 07, 2009
    Mohan, That is corrent IBrowser3 has been deprecated. However, you can still access it following the instructions in the blog post. Thanks! Mike

  • Anonymous
    November 09, 2009
    I tried this way IDispatch dispatch = NULL; IWebBrowser2 browser3 = NULL; m_spIWebBrowser2->get_Document(&dispatch); dispatch->QueryInterface(IID_IWebBrowser2, (void)&browser3); but browser3 is NULL... Am I missing something here?? Please let me know

  • Anonymous
    November 09, 2009
    Try this: LPDISPATCH pDisp=NULL; // Get the dispatch interface m_spIWebBrowser2->get_Document(&pDisp); if (pDisp==NULL)    return -1; IBrowser3 * pBrowser3; HRESULT hRes = pDisp->QueryInterface(IID_IBrowser3, (LPVOID*)&pBrowser3); … pBrowser3->Release(); Thanks, Mike

  • Anonymous
    February 20, 2010
    IBrowser3 has not been compiled successfully on wm 6.

  • Anonymous
    February 21, 2010
    Fll - For a compiled working sample see here: http://cid-e91b74403814953e.skydrive.live.com/self.aspx/BrowserWithGestures/BrowserWithGestures.zip Thanks, Mike

  • Anonymous
    June 23, 2010
    Hi mjf, Could you point me in the right direction to disabling selection in a C# .net 3.5 CF application?