Friday, October 19, 2007

The edit control under Windows Mobile 2003 and 5.0

After publishing my last article, I found out an interesting thing about the edit control on a Windows Mobile 2003 Pocket PC device: the up and down arrow keys behave differently from the edit control in Windows Mobile 5. In WM5, the single line edit control responds to the up and down navigation keys by setting the focus to the parent window. When this happens, the parent window receives the corresponding WM_KEYUP messages and thus is able to set up a navigation mechanism. Not so with the Windows Mobile 2003 edit control. This version of the control seems to "eat" these messages so the parent has no clue about the requested user navigation. This became quite apparent on my implementation of the CFormListCtrl: the navigation would not work.

This problem was quickly solved by adding the OnKeyDown message handler to the CCeEdit class and forcing the control to set the focus to the parent window whenever an up or down navigation keys are detected. Voilá!

7 comments:

ARNavPoch said...

Hi João Paulo,

There is another difference between WM5 PPC edit control and 'usual' edit controls: on desktops, smartphones and ppc 2002/2003 when the user enters VK_RETURN in a single line edit, the parent receives an IDOK WM_COMMAND message. In WM5 and WM6 ppcs, this does not happen. Or do I miss something?
cheers,
AR

João Paulo Figueira said...

Hi Alain,

Thank you for this input - I never noticed this difference and maybe I will have to look at the code again. I will be porting the code to WTL pretty soon and your comments will be invaluable. BTW, I just noticed that WTL 8.0 dropped the wizards for eVC3 and 4. Any workarounds?

Regards,
JP

ARNavPoch said...

Hi João Paulo,

I am not far from finishing a CodeProject article presenting a set of nonstandard templateless dialog classes including a desktop and mobile CInPlaceEditor. Hopefully it should be out before or during next week-end.

VC6/eVC appwizards use MS code that is not Open Source, so they were dropped since WTL 7.5. The solution is to use the VS2005 Mobile Wizard, check generate eVC compatible code (which will disable some options as ATL::CString support or DRA) and import the generated project in eVC (3 or 4).

cheers,
AR

ARNavPoch said...

Well, the article is a little late. This article is not far from end. Meanwhile you may download the associated project at http://www.codeproject.com/script/profile/upload/161329/DialogX.zip.
Comments welcome.

João Paulo Figueira said...

Unrelated to your post: Is there a CStdPropertyPage? The standard property sheet does not cover the main frame toolbar, so do I have to implement my own?

ARNavPoch said...

In your class override CPropertySheetImpl::void OnSheetInitialized(). This member will be called after complete initialization of the sheet and pages.
You may there call AtlCreateEmptyMenuBar(HWND hWnd, bool bSip = true) or AtlCreateMenuBar(HWND hWnd, UINT nToolBarId = ATL_IDW_TOOLBAR, DWORD dwFlags = 0, int nBmpId = 0, int cBmpImages = 0, COLORREF clrBk = 0) or resize your sheet (actually resize the sheet tab control).

ARNavPoch said...

Well, this article is now out: DialogX.

CEmptyDialogImpl may be of help to port your calculator control, which I love, and CInPlaceEditor for in place editing :)

ANY comments welcome!
cheers,
AR