Welcome to MSDN Blogs Sign in | Join | Help
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: ,,
Posted: Tuesday, July 21, 2009 11:08 PM by mjf

Comments

Teun van Run said:

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).

# July 22, 2009 10:15 AM

kwatts said:

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.

# September 3, 2009 8:59 PM

mjf said:

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

# October 1, 2009 10:38 AM

Mohan said:

Is there a way to enable Gesture Scroll on MiniPIE sample?

# November 4, 2009 2:37 PM

mjf said:

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

# November 5, 2009 11:11 AM

Mohan said:

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

# November 6, 2009 10:45 AM

mjf said:

Mohan,

That is corrent IBrowser3 has been deprecated. However, you can still access it following the instructions in the blog post.

Thanks!

Mike

# November 7, 2009 1:16 PM

Mohan said:

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

# November 9, 2009 2:34 PM

mjf said:

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

# November 9, 2009 2:57 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker