C, C ++ enables the black box full screen display on the console, and the box full screen display

Source: Internet
Author: User

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

 

Related Article

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.