Detection of 1000

zhaozj2021-02-16  72

See: http://www.vccode.com/file_show.php? Id = 2226

I used to have similar procedures I have done it myself, the principle is the same, and the difference is that the amount of each array element is 10, and this program uses 1,000,000 to make progress, good! !

Here is a primary discussion, don't laugh, I don't know MFC.

I want this program to knock back in the text box and press the button. This is very natural idea. According to VB's ideas, I found the available events of this text, and there is no onKeyPress. I thought: I won't be so basic, I am not too much.

It is known that there are two roads to walk: 1. Override onok (), because on the current form (? There are individual exceptions), this method is executed. Because there is only one text box that can receive the carriage return, it can naturally call the method directly. But if there are multiple, what is the distinction? The answer is: getfocus () will return the current focus element, do the discrimination, code: void cbigdatedlg ::Onok () {if (getfocus () == getdlgitem (IDC_Value) This-> oncalculate ();} 2, The last method is not universal, so it is not recommended, it is best to use the following method: Reword PretranslateMessage (MSG * PMSG) !! No longer expressed, the code is as follows: BOOL CBIGDATEDLG :: PretranslateMessage (MSG * PMSG) {// Process IDC_Value Message IF (PMSG-> hwnd == getdlgitem (IDC_Value) -> getSafehWnd ()) {// Avoid Right-click Menu IF (PMSG-> Message == WM_RBUTTONUP || PMSG-> Message == WM_CONTextMenu) Return True; // Consider the case where the user press Enters the carriage return (pmsg-> message == wm_keydown && pmsg-> wparam == vk_return) {CWND * AW = this-> getFocus (); (CEDIT *) AW) - > Setsel (0, -1); // At the same time, select all the text in the text box, more convenient to use! ! THIS-> oncalculate ();}}

Return CDIALOG :: PretranslateMessage (PMSG);

Through this example, I started a little understanding of the message loop.

Good luck !!

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

New Post(0)