1000 factorial Processing

Source: Internet
Author: User

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

I have done similar programs myself in the past. The principle is the same. What's different is that the hexadecimal value of each of my array elements is 10, and this program uses 1,000,000 as the hexadecimal value, okay !!

 

Below is a preliminary discussion. Don't laugh. I don't know much about MFC.

I want to make this program play the same role as pressing the press button in the text box. This is a natural idea. According to the VB idea, I found the available event of this text box, and there was no such thing as onkeypress. I thought: no such basic things will happen.

Find the half-day materials to know that there are two ways to go:
1. Rewrite onok () because it is in any text box (? If you press enter, this method is executed. In this example, there is only one text box that can receive the carriage return. You can directly call the method. But if there are multiple, what is the difference? The answer is: getfocus () will return the current focus element. You just need to identify it. Code:
Void cbigdatedlg: onok ()
{
If (getfocus () = getdlgitem (idc_value ))
This-> oncalculate ();
}
2. The previous method is not generic, so it is not recommended to use it. It is best to use the following method: override pretranslatemessage (MSG * PMSG )!! The Code is as follows:
Bool cbigdatedlg: pretranslatemessage (MSG * PMSG)
{
// Process the idc_value message
If (PMSG-> hwnd = getdlgitem (idc_value)-> getsafehwnd ())
{
// Avoid context menu
If (PMSG-> message = wm_rbuttonup | PMSG-> message = wm_contextmenu)
Return true;
// Consider the case where you press enter in the text box
If (PMSG-> message = wm_keydown & PMSG-> wparam = vk_return)
{
Cwnd * aw = This-> getfocus ();
(Cedit *) AW)-> setsel (0,-1); // select all text in the text box for ease of use !!
This-> oncalculate ();
}
}

Return cdialog: pretranslatemessage (PMSG );
}

 

In this example, I started to understand the meaning of the message loop.

Good luck !!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.