Thursday, January 21, 2016

mobile development: on the edit box




            


Brother just started learning mobile programming, do first a dialog box, put an edit box, when running the program, enter the text in the edit box if you make a mistake and want to press "backspace" key to re-enter, but a Press the key to exit the program it! How to solve it?
Reply:
You put the code Tieshanglai help you see. Nothing to write, how to help you see !!
Reply:
Ah did not write the rest of the code is to put a text on the dialog box and a button, and then compile and run the program, he says the situation has emerged. I use Mobile 5.0 for Smartphone. The above said, "backspace" key is the return key on the Smartphone has, this key is used to edit the text when backspace.
There is really no code stickers ah, I do not know I say clearly no.

Reply:
back in case you do not have a default os overloaded process to close the current dailog

Workaround

Send SHCMBM_OVERRIDEKEY rewrite VK_BACK's behavior when init dailog

HWND hwndMenuBar = SHFindMenuBar (m_hWnd);
SendMessage (hwndMenuBar, SHCMBM_OVERRIDEKEY, VK_TBACK, MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY, SHMBOF_NODEFAULT | SHMBOF_NOTIFY));

dailog response wm_hotkey then goes

LRESULT CMyDlg :: OnHotKey (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & amp; bHandled)
{
if (VK_TBACK == HIWORD (lParam))
{
bHandled = true;
SHSendBackToFocusWindow (uMsg, wParam, lParam);
}
return 0;
}


Reply:
Thank luandao2000 (Chen edge)!
Solve the problem, but I OnHotKey (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & amp; bHandled) such messages function, the compiler error, so I changed: OnHotKey (WPARAM wParam, LPARAM lParam); on it. So it is the following scenario:

Send SHCMBM_OVERRIDEKEY rewrite VK_BACK's behavior when init dailog
HWND hwndMenuBar = SHFindMenuBar (m_hWnd);
SendMessage (hwndMenuBar, SHCMBM_OVERRIDEKEY, VK_TBACK, MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY, SHMBOF_NODEFAULT | SHMBOF_NOTIFY));

Next, define the message processing function:
afx_msg LRESULT OnHotKey (WPARAM wParam, LPARAM lParam);

ON_MESSAGE (WM_HOTKEY, & amp; CfirstDlg :: OnHotKey)

LRESULT CfirstDlg :: OnHotKey (WPARAM wParam, LPARAM lParam)
{
UINT idHotKey = (UINT) HIWORD (lParam);
if (idHotKey == VK_TBACK)
{

}
return 0;
}

Reply:
I posted was for WTL message handling Oh

No comments:

Post a Comment