This back key is very strange. If it is not processed by default, even if there is an edit control in the current dialog, it still does not act as a back-to-delete key, or closes the current dialog box, roll back to the previous one. The solution is also simple. When you press back, the OS will throw a wm_hotkey message. We can capture this message and rewrite the back key behavior.
CodeAs follows:
When oninitdialog, shcmbm_overridekey is sent to override vk_back.
Hwnd hwndmenubar = shfindmenubar (m_hwnd );
Sendmessage (hwndmenubar, shcmbm_overridekey, vk_tback, makelparam (shmbof_nodefault | shmbof_notify, shmbof_nodefault | shmbof_notify ));
Then, when the dailog responds to the wm_hotkey, it performs the following processing:
Lresult cmydlg: onhotkey (uint umsg, wparam, lparam, bool & bhandled)
{
If (vk_tback = hiword (lparam ))
{
Bhandled = true;
Shsendbacktofocuswindow (umsg, wparam, lparam );
}
Return 0;
}
Write Based on the wtl framework. If you use the original SDK, make some modifications on your own.