VC entry book (10)

zhaozj2021-02-16  25

news

He Zhidan

PretranslateMessage function as the name suggests before, do something before, we can block a key or a command. Here are some of the common messages. These information is placed in PMSG .wm_keydown nvirtkey = (int) wparam; / * Valic key value, and ASCLL code has many places * / lkeydata = lparam; / * and hardware related * / wm_char chcharcode = (tchar) wParam; LKEYDATA = LPARAM; WM_COMMAND WNOTIFYCODE = HiWord (WPARAM); wiD = loword ); hwndCtl = (HWND) lParam; WM_LBUTTONDOWN fwKeys = wParam; // xPos = LOWORD (lParam); // mouse abscissa yPos = HIWORD (lParam); // mouse ordinate fwKeys MK_CONTROL MK_LBUTTON MK_MBUTTON MK_RBUTTON MK_SHIFT WM_MOUSEMOVE fwKeys = wParam ; xPos = LOWORD (lParam); yPos = HIWORD (lParam); the following example illustrates, in common usage PreTranslateMessage .BOOL CPreTranslateDlg :: PreTranslateMessage (MSG * pMsg) {if (WM_KEYDOWN == pMsg-> message) if (0x30 == (int) PMSG-> WPARAM) {return true; / * Prohibited from entering 0 (asCll 0x30) * /} in the edit box

IF (WM_CHAR == PMSG-> Message) if ('a' == (tchar) PMSG-> wparam) {return true; / * Prohibits enter 'a' * /} if in the edit box (WM_MOUSEMOVE == PMSG- > message) if (mk_control & pmsg-> wparam) / * Display information * / {int xpos = loword (PMSG-> lparam) when Ctrl is pressed down, display information * / {int xpos = loword (pmsg-> lparam); int ypos = half CString str; str.format ("Coordinate% D% D", XPOS, YPOS); AFXMessageBox (STR);

IF (wm_command == pmsg-> message) if (id_1 == loword (pmsg-> wparam) // disable menu item ID_1, Note The button is sent to BN_Clicked {Return True;} Return CDIALOG :: PretranslateMsSage (PMSG); }

转载请注明原文地址:https://www.9cbs.com/read-25720.html

New Post(0)