Add runtime debugging window for the MFC Program

Source: Internet
Author: User
1. Establish an MFC project

1. Select "MFC Application" to create a project;

2. Select "dialog based" for "application type" in the Wizard ";

3. Click "finish" to complete the wizard;

2. Add console debugging window

1. Add the header file:

# Include "conio. H"

2. Add the following to the oninitdialog function:Code:

Allocconsole (); cprintf ("init \ r \ n ");

:

3. Compile and runProgram, The effect is as follows:

3. Add command line parameter judgment

If the released program has a console window that looks strange, you can add command line parameters to the MFC program to determine whether to enable the console debugging window. Of course, you can also set "allocconsole (); "This line of code is commented out.

I have an example here, but I have determined the number of command line parameters. This reader can modify it as needed.

1. Add the following code to the oninitdialog function:

If (_ argc> 1) {allocconsole (); cprintf ("init \ r \ n ");}

Compile and run the program.

2. Running Effect

Here we mainly demonstrate the Running Effect of command line parameters:

You can also create a shortcut, add parameters to the properties, and double-click it:

Okay, that's all. I hope it will help you.

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.