C, C ++ enables the black box full screen display on the console, and the box full screen display
Sometimes C and C ++ run a lot of data, or a freshman wants to run the Black Box console C and C ++ out of the student management system interface, is it small? The following is a full screen function. You only need to call it in the first line of the main function. Then, the rest will not be affected. (This function can be included in windows. h)
1 void FullScreen(){ 2 HWND hwnd=GetForegroundWindow(); 3 int x=GetSystemMetrics(SM_CXSCREEN)+300; 4 int y=GetSystemMetrics(SM_CYSCREEN)+300; 5 char setting[30]; 6 sprintf(setting,"mode con:cols=%d lines=%d",x,y); 7 system(setting); 8 SetWindowPos(hwnd,HWND_TOPMOST,0,0,x+300,y+300,NULL); 9 MoveWindow(hwnd,-10,-40,x+300,y+300,1);10 printf("\n\n");11 }
The following describes some basic parameters of the above functions. Of course, you can ignore them here and simply use the above functions.
1) GetForegroundWindow (). This function obtains the handle of the current Working window. Here is the console.
2) The GetSystemMetris function has only one parameter. The SM_CXSCREEN parameter is used to obtain the screen width.
3) You should know that system ("mode con: cols = x lines = y"); this statement can set the console size. However, the system contains a string variable and does not know the screen size beforehand. Therefore, you need to use an auxiliary character array setting to pass the parameter.
Int sprintf (char * buffer, const char * format, [argument]… ); The return value of the function is the length of the string, which is passed to the buffer.
4) The remaining SetWindowPos and MoveWindow will be read by Baidu.
2015-6 6