Hi All,
I was hoping that someone could help me with a change in the Window Mobile 2005 Common Control behavior compared to Windows Mobile 2003 and older.
What I have noticed is that in WM2005 the keyboard/SIP events sent to Dialog applications have changed... in that keystrokes are handled by the control itself and the parent dialog does not receive the keyboard events or if it does it acts on them differently. For example, in WM2005 when the Enter key is pressed while on a dialog box with edit control(s) on it, the focus will jump from one to another and circles back. However, in the older versions of Windows Mobile (2003 and 2002) and all the plain Windows CE OSs that I have worked on, the Dialog box would get the Enter Key response in the form of WM_COMMAND, IDOK Message.
I was hoping that some one could help in forcing the Windows Mobile 2005 Common Controls, Dialog Boxes, and ,...etc. to behave as the older versions did, Windows Mobile 2003/2002.
Thanks
Arash

Change in Common Control UI Behavior in Windows Mobile 2005, Why???
Runningwolf
Moving this thread to native forum.
Manav
Naolin
Did you ever figure this out
Thanks
Richard
No-spam Sam
All of the following code is based on tril and error experience.. No one either knows or was willing to input.. so I hacked around it.
This hack!! works in MFC Dialog based applications.. I have not tried to do this in none MFC native apps.
There are two PreTranslateMessage functions One in CDialog and CWinApp Class, CMyDlg is from CDialog and CMyApp is from CWinApp.
I have a MyPreTranslateMessage function in CMyDlg which is called from CMyDlg::PreTranslateMessage and any other overloaded PreTranslateMessage in your sub classes inherited from CMyDlg.
As I mentioned the code is 90% trial and error based on where, when, and how the WM_* messages are handed by Dialog class and Common Controls on it.
I have commented the code for as much as I can understand this weird behavior. However, the debugger is more of your best friend then what I can explain.
BTW, This one handed keyboard thing seem to be in ALL Windows Mobile 5 (Pocket PC and Smart Phones) and not in Windows CE 5.x which WM 5.0 is based on.
Hope this helps you...
Arash
All of the following code is based on tril and error expriance.. No one either knows or was willing to input (Microsoft !!!)..
This hack!! works in MFC Dialog based application.. I have not tried to do this in none MFC native apps.
There are two PreTranslateMessage functions One in CDialog and CWinApp Class, CMyDlg is from CDialog and CMyApp is from CWinApp.
I have a MyPreTranslateMessage function in CMyDlg which is called from CMyDlg::PreTranslateMessage and any other overloaded PreTranslateMessage in your sub classes inheritted from CMyDlg.
As I mentioned the code is 90% tril and error based on where, when, and how the WM_* messages are handed by Dialog class and Common Contorls.
I have as much comments as I understand this weird behaviour in the code. however, the debugger is more of your best friend then what I can explain.
BTW, This OneHanded Keyboard thing seem to be in ALL Windows Mobile 5 (Pocket PC and Smart Phones) and not in Windows CE 5.x which WM 5.0 is based on.
Hope this helps you...
Arash
// --------------------------------------------------------------------
// CLASS: CAceDlg
// FUNCTION: [virtual] PreTranslateMessage( in MSG* i_ptMsg )
// PURPOSE: Finesse Windows Messages Before Standard
// Processing Is Performed (TranslateMsg/DispatchMsg)
// PARAMETER(S):
// i_ptMsg Message To Examine For Modification
// RETURNS: [BOOL]
// NONZERO Message Was Translated And Should Not Be Dispatched
// 0 The Message Was Not Translated And Should Be Dispatched
// --------------------------------------------------------------------
BOOL CMyDlg::PreTranslateMessage( in MSG* i_ptMsg )
{
if (CMyApp::IsWindowsMobile5())
{
switch(i_ptMsg->message)
{
case WM_KEYDOWN:
case WM_KEYUP:
switch (i_ptMsg->wParam)
{
case VK_RETURN: //Only When User Presses Enter/Return
{
if (GetSafeHwnd() != i_ptMsg->hwnd) //If Message is NOT Intended for the Dialog, and sent to child controles then
return PostMessage(i_ptMsg->message, i_ptMsg->wParam, i_ptMsg->lParam); //Reroute Message and to the current dialog.
}break;
}
}
}
// KEY DOWN HELPER FUNCTION(S)
// ------------------------------------------------------------
if( i_ptMsg->message == WM_KEYDOWN )
{
// PRIORITY PROCESSING
// ----------------------------------------------------
if( PreMsgFirst(i_ptMsg) ) return( TRUE );
// TEST FOR IGNORE EVENT(S)
// ----------------------------------------------------
if( PreMsgIgnore(i_ptMsg) ) return( TRUE );
// ----------------------------------------------------
if( CMyApp::_IsControl() && PreMsgControl(i_ptMsg) ) return( TRUE );
// FUNCTION KEY PROCESSING
// ----------------------------------------------------
if( CMyApp::_IsFunction() && PreMsgFunction(i_ptMsg) ) return( TRUE );
// STANDAR KEY PRROCESSING
// ----------------------------------------------------
if( PreMsgStandard(i_ptMsg) ) return( TRUE );
}
// RETURN INHERITED FUNCTION
// ------------------------------------------------------------
return( CMyDlg::MyPreTranslateMessage(i_ptMsg) );
}
BOOL CMyDlg::MyPreTranslateMessage(MSG* pMsg)
{
BOOL Return = FALSE;
if (CMyApp::IsWindowsMobile5())
{
switch(pMsg->message)
{
case WM_KEYDOWN:
case WM_KEYUP:
switch (pMsg->wParam)
{
case VK_LEFT: //These keys should be returned TRUE (MY Application has handled it do not do dispatch)
case VK_RIGHT:
case VK_DOWN:
case VK_UP:
Return = TRUE;
break;
case VK_RETURN:
{
if (GetSafeHwnd() == pMsg->hwnd) //Message Intended for the Dialog
Return = CDialog::PreTranslateMessage(pMsg); //At The End it Calls the ::IsDialogMessage(hWnd, pMsg) Function
// ::IsDialogMessage(hWnd, pMsg) is the function that causes all the greaf
}break;
default: //there all other Vitual Key messages seem to have retained their original behavoiur and we want them to be handled as they are
Return = CDialog::PreTranslateMessage(pMsg);
}break;
default: //there all other messages seem to have retained their original behavoiur and we want them to be handled as they are
Return = CDialog::PreTranslateMessage(pMsg);
}
}
else //Any device older then or not WM5
{
Return = CDialog::PreTranslateMessage(pMsg);
}
return Return;
}
-----------------------------------------------------------------------------------------------------------------------------------
#include <iphlpapi.h>
#include <winioctl.h>
BOOL CMyApp::PreTranslateMessage( MSG* i_ptMsg )
{
// MODIFIER KEY RESET
// ------------------------------------------------------------
// DO Whatever
// .....
// .....
//If you notice the VK_ENTER is Missing... That is handled in the Dialog class
//CMyDlg::MyPreTranslateMessage and CMyDlg::PreTranslateMessage
BOOL Return = FALSE;
if (CMyApp::IsWindowsMobile5())
{
switch(i_ptMsg->message)
{
case WM_KEYDOWN:
case WM_KEYUP:
switch (i_ptMsg->wParam)
{
case VK_LEFT: // Call The base class's PreTranslateMessage function but return FALSE, (I CMyApp did not handle it please dispatch the message)
case VK_RIGHT: // The application PreTranslateMessage is called frist before dispatch so if not handled it will call the Active Dialogs
case VK_DOWN: // PreTranslateMessage function.
case VK_UP:
CWinApp::PreTranslateMessage(i_ptMsg);
break;
default:
Return = CWinApp::PreTranslateMessage(i_ptMsg);
}break;
default:
Return = CWinApp::PreTranslateMessage(i_ptMsg);
}
}
else
{
Return = CWinApp::PreTranslateMessage(i_ptMsg);
}
// RETURN INHERITED FUNCTION
// ------------------------------------------------------------
return( Return );
}
// --------------------------------------------------------------------
// CLASS: CMyApp
// FUNCTION: [virtual] GetOSVersion( void )
// PURPOSE: Get OS Version and Type
// PARAMETER(S): DWORD &dwMajor, DWORD &dwMinor, BOOL &bPocketPC
// RETURNS: [bool]
// --------------------------------------------------------------------
BOOL CMyApp::GetOSVersion( DWORD &dwMajor, DWORD &dwMinor, BOOL &bPocketPC)
{
BOOL bReturn = TRUE;
static TCHAR szOS[MAX_PATH] = _T("");
static OSVERSIONINFO osvi = {0, 0, 0, 0, 0, _T("")};
if ( szOS[0] == 0 )
{
DWORD dwType = SPI_GETPLATFORMTYPE;
DWORD dwRetunSize = 0;
bReturn = KernelIoControl(IOCTL_HAL_GET_DEVICE_INFO, &dwType, sizeof(dwType), szOS, sizeof(szOS), &dwRetunSize);
}
if (bReturn)
{
if (osvi.dwMajorVersion == 0)
{
osvi.dwOSVersionInfoSize = sizeof( osvi );
bReturn = GetVersionEx( &osvi );
}
if ( bReturn )
{
dwMajor = osvi.dwMajorVersion ;
dwMinor = osvi.dwMinorVersion ;
bPocketPC = TRUE;
CharUpper(szOS);
if (_tcsstr(szOS, _T("POCKETPC")) == NULL)
bPocketPC = FALSE;
}
else
{
dwMajor = 0 ;
dwMinor = 0 ;
bPocketPC = FALSE;
}
}
return( bReturn );
}
BOOL CMyApp::IsWindowsMobile5()
{
DWORD dwMj, dwMi;
BOOL bPPC;
return (CMyApp::GetOSVersion(dwMj, dwMi, bPPC) && dwMj >= 5 && bPPC);
}