Fullscreen

Mar 2, 2014 at 7:45am
Always when programs run they don't open in full screen by default. You must go to properties an change the settings. But i was wondering if there's a way you can code your program to do that when it runs without needing to go to properties.

Mar 2, 2014 at 8:00am
set the window to fullscreen to begin with.
Mar 2, 2014 at 11:20am
@metulburr:I asked if there's a function of doing that not from properties.
Example:When you open your browser it opens in fullscreen.
Mar 2, 2014 at 1:30pm
A standard C++ program doesn't really have control over that. The console window is not part of your program. It's just what's being used to display the output and input of your program. It is possible to run the program without showing a console window. It's even possible to redirect the input and output to files.

If you really want to have control over the console window you will have to use platform dependent functions or special libraries to do that, but I'm not sure how many of them actually allow you to put the console window into fullscreen mode.

If you are using some kind of graphics/GUI library to do real graphics (no console window) then you can probably use the same library to put the window in fullscreen mode.
Last edited on Mar 2, 2014 at 1:46pm
Mar 2, 2014 at 4:30pm
@jasongog
This may be of help. Creates a console window 180 x 82

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Resize Console.cpp : main project file.

#define _WIN32_WINNT 0x0501
#include <conio.h> // Just for the _getch() command at the end of program
#include <iostream>
#include <windows.h>

using namespace std;

int main()
{
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);

    COORD a;
    a.X = 185;// Change for maximum width of your desired console window
    a.Y = 300;

    SMALL_RECT rect;
    rect.Top = 0;
    rect.Left = 0;
    rect.Bottom = 82;
    rect.Right = 30;


    SetConsoleScreenBufferSize(handle, a);

    SetConsoleWindowInfo(handle, 1, &rect);

    cout << "Making console bigger" << endl;

    for (int i=0; i< 150; i++)
    {
        //rect.Bottom++;
        rect.Right++;
        int x = SetConsoleWindowInfo(handle, 1, &rect);
        if (x == 0)
        {
            cout <<  GetLastError() << endl;
        }
        // 6  - handle is invalid
        // 87 - invalid parameter

        Sleep(100);
    }
	cout << endl << endl << endl << "Press a key to close the Console" << endl << endl;
    _getch();
    return 0;
}
Mar 3, 2014 at 6:57am
Thanks everyone. I will click on the solve button now.
Topic archived. No new replies allowed.