Tag Archives: c++

The problem of C + + compile result window flash by

Problem: When you first learn C++ to write Win32 Console Application using a different compiler, the resulting window may flash and disappear.
Some compilers are very good, and there are similar solutions in the example program. For example, in DevC ++, when creating a new non-empty C++ class, return 0; Before this: system(“PAUSE”); In Visual Studio there is no flash if you follow the steps, but when we press the shortcut key F5, the result will still flash. We can do this in return 0; STD ::cin.ignore(STD ::cin.rdbuf()->; in_avail()+1); That way it will show up, not just go over it. If you just want to see the result, there’s another way, and that’s in return 0; I’m going to say while(1);

In vs programming, the code of Ctrl + F5 is flashback

When VS compiles and runs the code, if there is no delay or some kind of response, the window will close immediately after running
Solution a:
in the main function and getchar ()

; add system(” pause “) to the main function
Solution 3:
right-click on the project, select properties, choose the linker, selection system, in the subsystem, the console this

the above methods are debug mode, the way of carrying the shortcut Ctrl + F5
in debug mode, just set a breakpoint in the main function, then one by one to debug

MFC flash screen solution

These two days I have been doing UI design, because the company did not use commercial Direct UI and other interface libraries. So the developers had to draw their own controls, so the task of writing the UI fell to me as a new coder. Then the problem I had been avoiding came up against me. Smecta.

problem a, own drawing background is hiding the interface on the original control, in order to solve this problem, but get me hanging silk maxed out.

a, painted a background, and then the area of access to all controls, make it invalid. So the problem was solved, but a new problem came, is the flash screen problem. This problem is caused by overwriting the background and control color. In other words, this scheme is eunuch.

> For this kind of scheme, I just thought, should be OK. But it’s too difficult. I don’t have the ability to do it.

> Set the dialog’s clipChildren property to true. When you draw a window, you cut out the area of the control and copy it back when it is finished. This property is customized for the drawing, so the above problem is solved with just one click. The solution turned out to be so simple.

if draw refresh frequently, this there is no doubt that the splash screen will appear.

Scheme 1, the use of double buffer, no pressure. So every time I draw it, I just paste it on.

2, in painting background brush set for NULL_BRUSH background before you leave. The system could not draw.

3, to draw the background of function (OnEraseBkgnd (pDC) CDC *) content to watch out, with the return true replacement, and then system, there is no way to use the default brush to draw the background. However, the latter two methods solve the flicker, but the interface can be a mess.

using GDI resource summary:

first of all, we all know this law have borrow have also, so when learning c + + so follow this rule, otherwise you will hit a wall.

when using handle with H, for example: the HBITMAP etc, after using DeleteObject remember;

For GDI wrapped classes with C, this is not necessary because the system has already freed them during object destructing. If you leave the system resource handle with the class Detach, then you need to take over the management of the system resource, otherwise the system resource leak will occur.

when using CDC, if the memory DC created after running out also need DeleteDc…..

Why does the result screen flash when visual studio runs the program?

When the console application in VS is running, the result screen will flash, whether using F5 or Ctrl + F5, and the result will not be visible. There are a lot of ways on the Internet, which is to add a pause statement to the program at the end or to get user input from the console statement. There’s a better solution:

Right click on your project entry, select the last item “Property/Properties” on the pop-up menu, and in the left column, find “Configuration Properties”

-> The linker – & gt; System, after clicking on the System item, subSystem in the right column configuring the value of the subSystem to “Console “.

After doing this, press Ctrl+F5 again and the program will stop at the console screen and prompt you to “Press any key to continue.” That’s the perfect solution.

Three solutions to flash back of program running result box under vs

When writing C/C ++ programs in VS, the result box will always flash away, and you can’t see the results of the program. This is really annoying, so here are three ways to solve it
 
Method one:
In the return 0; Before the statement, add a getchar(); In this case, getchar will wait for input, and the result box will display the result of the program.
 
As shown in the figure below:


 
Method 2:
Add the statement system(“pause”) at the end of the program; , plus the header file #include< stdlib.h> “, which will display the results after running them and prompt you to press any key to continue.
 
As shown in the figure below

 

 
Method 3:
To modify the project configuration, right-click on the project, select Properties from the right-click menu, and then select “Configuration Properties –>” from the list to the left of the pop-up dialog. The linker – & gt; System “, and then in the list on the right, in the first “subsystem” value, select “Console (/SUBSUSTEM:CONSOLE)”
As shown in the figure below:



 
 
From:
https://blog.csdn.net/rannianzhixia/article/details/66968219?locationNum=6& fps=1

The problem of running result window flash of vs2015

Most novices writing console programs in VS for the first time will have a problem with a flash window of results. Most of the time this is not caused by a programming error, but by a detail we have overlooked.

The quick and easy solution is as follows:
1. Open the configuration window in the following order: Project ->; Property – & gt; Configure properties ->; The linker – & gt; System – & gt; The subsystem

2. Click the down arrow on the right side of the SUBSYSTEM, select the link option “/ CONSOLE”, apply and confirm it.

The reasons and common solutions of vs flash back on the road of C + + Learning (with reasons attached)

First of all, it’s normal to flash and go away.

Because the program statement is executed sentence by sentence, nothing makes it pause, at the speed of computer execution, of course, flash by.

What we need to do is make the system wait and pause so that it doesn’t flash back (some compilers automatically add this feature at the end of the code to prevent novice users from seeing the output).

1) add system(“pause”) before return;
Note: system() is the call to the system command; Pause command; “Press any key to continue..”

;
;
;
Note: getchar reads the next character, so it “pauses” while waiting for us to type.
It’s worth noting that sometimes you might need to add two getchar(), because the first getchar() might eat the carriage return or something like that.

3) Press Ctrl +F5 to run
Note: Ctrl +F5 is a program that debugs without debugging. It automatically “pauses” at the end of the program, so the DOS command prompt “Press any key to continue….” is added.
The little triangle we clicked on, which starts debugging (F5), does not automatically add “pause”, so it will flash past.

The above is only the idea after I consult the data to think, welcome everyone fellow middlemen to give correct, next will be very grateful!

Solution to the flash of visual studio console program output window

     
When you first come into contact with Visual Studio, most people will write a Hello World program to try. Some people will find that the output window will flash past after execution, and there is no “Press any key to continue”. This happens in both Visual Studio 2008, 2010, and 2012, and some people might do it one of two ways:

Add system(“pause”) or getchar() at the end of the program code. In fact, this is a command under DOS.

 

The problem is that when you Press F5, the correct one should be Ctrl+F5, and the window will display Press any key to continue… That’s it. You can also see the results of the program run.

This is because F5 is in Debugging mode, where the window does not remain open once the application finishes running. If CTRL +F5 is in Start Without Debugging mode, you’ll be able to see the results.

 

If you press Ctrl+F5 and it still flashes, then use the following Settings:

Right-click on Project –>; Property – & gt; Configure properties –> Connector – & gt; System – & gt; Subsystem (on the right side of window) –>; SUBSYSTEM:CONSOLE Drop down SUBSYSTEM selection CONSOLE

Solution of command line window flashback when visual studio runs C + + program

(By Tan Tan)
First, problem description
The original code looks like this:

#include <iostream>
 
int main()
{
    std::cout << "Hello World!\n";
    return 0;
}

The function is to print Hello World! From a command line window. However, the command line window will flash back as soon as I run it, and I haven’t even had time to read my Hello World!!
Second, solutions
Tried several methods of website, the following several works:
remember the following words are added before the return!!!!!!!!!
1. Add this sentence before return 0:

getchar();

2. Add this sentence before return 0:

system("pause");

3. Add this sentence before return 0:

cin>>name

The principle of these methods is the same, all want the command line window to wait for you to enter a signal before proceeding to execute, you do not enter a signal better stop there. Getchar () and cin> > The name is all about identifying what you’re typing, and the system(” pause “) should be free to enter a single character without identifying what you’re typing. Another way to do this is to write cin.get () before it; Get what you type, not type it and then execute it.

Lack of msvc120d.dll library

When the program is written and the executable also depends on the library to be migrated to another machine that does not have VS installed, the missing MSVC will be reported… DLL library problem, that’s because
If you’re writing an MFC program, you need to set it to statically import the MFC library. If you’re writing a Win32 program, you need to cancel the MFC library and select the standard library.
You also need to select the Release version, not the Debug version