Article Difficulty: Beginners
About T9 Input method of the core program (provided by my friend Nix), a total of two documents, one is NixInputMethod.h, there is a t9.c; See appendix.
The implementation of the specific input method is as follows:
1. First create a dialog box, and then put two controls in it: Idc_edit1 and Idc_word (static control)
2. In order to achieve the input in the edit, the static will appear in the intelligent function, so our implementation is as follows:
A The overloaded function PreTranslateMessage enables it to capture all the events of the keyboard, so it is implemented as follows:
BOOL Cmy11dlg::P retranslatemessage (msg* pMsg) { try { cwnd* Pctrl = GetFocus (); /* * Can be built by enter the cursor focus of the switch */ if (pmsg->message = = Wm_keydown && getasynckeystate (vk_tab)) { Get the char index of the caret position int NPOs = LoWord (M_myeditctl.charfrompos (M_myeditctl.getcaretpos ())); Select Zero chars M_myeditctl.setsel (NPOs, NPOs); Then replace that selection with a TAB M_myeditctl.replacesel ("/t", TRUE); No need to does a msg translation, so quit. That's way no further processing gets done return TRUE; } else if (Getasynckeystate (Vk_return))//Enter { Switch (Pctrl->getdlgctrlid ()) { Case IDOK: if (!reset) { AfxMessageBox ("OK"); reset = 1; } else { reset = 0; GetDlgItem (idc_static)->setfocus (); } Break Default Pmsg->wparam = Vk_tab; } } else /* * Through 1, 2, 3 ... Select the first few words */ if (pmsg->message = = Wm_keydown && (isdigit (pmsg->wparam) | | (Pmsg->wparam >64 && Pmsg->wparam < 91))) { CString str; if (IsDigit (Pmsg->wparam)) { GetDlgItem (Idc_word)->getwindowtext (str); char* temp = str. GetBuffer (100); Char zi[3]; zi[0] = temp[ |