Advertisement

Console Window Size

Started by January 09, 2003 02:08 PM
4 comments, last by Tech19 21 years, 10 months ago
How can i change the size of the console window? eg. make it 24 x 24 characters? thanks
Assuming you are using Windows and C or C++:
You need to call SetConsoleScreenBufferSize() to adjust the size of the screen buffer, then call SetConsoleWindowInfo() to change the size of the window itself.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Advertisement
or in other words:


      #include <windows.h>int main(){   HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);       //You need this to use SetConsoleScreenBufferSize()   COORD cdScreenSize = {24, 24};   // This will be the size you want the console to be   SetConsoleScreenBufferSize(hOutput, cdScreenSize);   return 0;}      


There ya go!

[edited by - Jeff D on January 9, 2003 5:09:56 PM]

[edited by - Jeff D on January 9, 2003 5:11:33 PM]
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
After experimenting this way doesn''t allow you to get lower than 80 X 25. Sorry.

Jeff D
Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton
Oops, my bad. You'll want to call SetConsoleWindowInfo() first, then call SetConsoleScreenBufferSize().

    SMALL_RECT windowSize;COORD bufferSize;bufferSize.X = 24;bufferSize.Y = 24;windowSize.Bottom = 23;windowSize.Top = 0;windowSize.Left = 0;windowSize.Right = 23;if(!SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &windowSize))	return 1;if(!SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), bufferSize))	return 1;    


[edited by - Martee on January 9, 2003 5:39:41 PM]
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Hmm Martee not bad, something in the Console functions I didn''t know!


Jeff D

Only thing I don''t like is that it starts so small thats really it

Suffered seven plagues, but refused to let the slaves go free. ~ Ross Atherton

This topic is closed to new replies.

Advertisement