Window resizing

Hello all, i have had recent trouble trying to get my win32 console window to fit my 1600 x 900 display making it full screen here is my code thanks in advance.

#include <iostream>
#include <windows.h>
#define _WIN32_WINNT 0x0500
#include <Windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <fstream>
#include <sstream>
#include <time.h>
#include <string>
#include <conio.h>

using namespace std;

void resize_windows (int height, int width);
void resize_windows();

int main ()
{

resize_windows(700, 700);


system("PAUSE");
return 0;
}

void resize_windows (int height, int breadth)
{
HWND console = GetConsoleWindow();
RECT r;
GetWindowRect (console, &r);

MoveWindow(console, r.left, r.top, height, breadth, TRUE);
}

This won't work because the console's width is limited by default to 80 characters. You need to alter the size of the screen buffer to be able to resize the screen.

This code shows the function calls you need to make to resize the buffer.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
HANDLE hOutput=CreateFile("CONOUT$",
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);

CONSOLE_SCREEN_BUFFER_INFOEX csbi;

GetConsoleScreenBufferInfoEx(hOutput,&csbi);

// Change elements of csbi here such as dwSize, dwMaximumWindowSize and srWindow which determine the size of the window

SetConsoleScreenBufferInfoEx(hOutput,&csbi);


(edit):

For next time, this question really belongs in the Windows Programming section of this forum - it's very windows-specific
Last edited on
Thank you all guys your help has been invaluable, do you know where i should post a section about my project.
Topic archived. No new replies allowed.