HomeQuestions and AnswersArticlesSamplesLibrariesForumsNewsLinks

Why does not keyboard navigation work with HTML control?

By Yaroslav Goncharov, February 05, 2003.

Question

HTML control does not respond to keyboard events in my Smartphone/Pocket PC 2002 application. On the Smartphone platform I don't have a touch screen and a keyboard is the only way to navigate and scroll. How can I enable keyboard navigation in the HTML control?

Answer

There are 2 aspects that can disable keyboard navigation: an invalid initial focus and a dialog-based parent.

A dialog-based parent consumes keyboard events and does not give a chance to the HTML control to get them. There are several possibilities to fix it, but for the simplest solution use a generic parent window instead of a dialog.

Another interesting point is a keyboard focus. The HTML control consists from 2 windows. You should set a focus to the inner window to enable keyboard navigation. A good place to do it is the end of the parent window's WM_CREATE handler.

HWND hWndInternal = GetWindow(hwndHtmlCtrl, GW_CHILD); SetFocus(hWndInternal);

Related resources

Discuss

Discuss this QA. Here you can write your comments and read comments of other developers.

  © 2002 Smartphone Developer Network | Want to be an author? | Contact Us