Friday, May 6, 2011

Windows Mobile - disable HOME button

Study how to disable Home Button of Windows Mobile, below is some finding:

Do the following to disable button:
1) In function OnInitDialog( ), implement logic as below:

//RegisterHotKey(this->m_hWnd, 0x0100, MOD_WIN, VK_THOME);
for (WORD i=0x01 ; i<0xff ; i++)
{ RegisterHotKey(this->m_hWnd, 0x0100 + i, MOD_WIN, i);
}

2) Handle preTranslateMessage as below:

BOOL CIMPDA_TestDlg::PreTranslateMessage(MSG* pMsg)
{ ....
if (pMsg->message == 0x201 pMsg->message == 0x312)
{ // 0x201: button of Phone Call/ Phone End, 0x312: button of Home, Back
::MessageBox(this->m_hWnd,L"Button is disabled",L"Test",MB_OK);
SHFullScreen(this->m_hWnd, SHFS_HIDESIPBUTTON SHFS_HIDESTARTICON);
return TRUE;

}
....
return CDialog::PreTranslateMessage(pMsg);
}

3) In function of OnExit( ), add code as below:

for (WORD i=0x01 ; i<0xff ; i++)
{ UnregisterHotKey(this->m_hWnd, 0x0100 + i);

}

Below code can be used to hide Windows Start ICON:

SHFullScreen(this->m_hWnd, SHFS_HIDESIPBUTTON SHFS_HIDESTARTICON);