PreTranslateMessage function Call DoModal () The following bug! appears when you close the dialog box
Cause analysis: in the PreTranslateMessage to obtain the corresponding m_hwnd,DoModal () modal dialog box exits,m_hwnd is not a valid window handle, Need to return rrue
Workaround: After you finish processing the keyboard message in PreTranslateMessage , do a couple of steps :
1. Reset Focus
2,return TRUE
Enter key: Enter the current selected module if (Pmsg->wparam = = Vk_return) {if (Countenter = = 2) {if (:: IsWindow (GetSafeHwnd ())) {pdlg-> Pdlgpgzb->onbnclickedbtadd ();// bn_clicked called DoModal ()////p: Return to the focus position && call Dlgmethod back return 1;pdlg->pdlgpgzb->setfocus ();pD lg->pdlgpgzb->m_list_method.setitemstate (0, LVIS_SELECTED| lvis_focused, lvis_selected| lvis_focused); Setcursorpos (120,210); return 1;}}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PreTranslateMessage DoModal () ASSERT (:: IsWindow (M_hwnd)