[SOLVED]Maximizing A Console Window

Ok, so I don't want my console app to run in full screen - but I would like it to run maximized. Only problem is I'm not to sure how to pull it off.

1
2
3
4
5
6
void SetWindowSize(int horizontal, int vertical)
{
	SMALL_RECT ScreenSize = {horizontal, vertical, horizontal, vertical};
	
	SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE) ,true , &ScreenSize);
}


I've been playing with this chunk of code trying to get what I want but no luck.I don't understand why the SMALL_RECT has 4 sides - so I did the stupid idea of just making the function take in two ints to change them to a perfect square technically.

All I want is the app to look how when you push the maximize button on the console window.

Thanks,
Myth.
Last edited on
Fixed:
1
2
3
4
5
6
7
8
9
10
void MaximizeWindow()
{
	CONSOLE_SCREEN_BUFFER_INFO info;
	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info);
	SMALL_RECT rc;
	rc.Left = rc.Top = 0;
	rc.Right = (short)(min(info.dwMaximumWindowSize.X, info.dwSize.X) - 1);
	rc.Bottom = (short)(min(info.dwMaximumWindowSize.Y, info.dwSize.Y) - 1);
	SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), true, &rc);
}
Last edited on
Topic archived. No new replies allowed.