Why is my Console Application limiting itself to half the screen?

N

Nathan Sokalski

I have a Console Application, and when I do a "Start Without Debugging" to
test it, everything works, but it will not allow me to make the window wider
than half my screen. Even if I maximize it, it takes the full height, but
only half the width. This is very annoying, because sometimes lines are
longer than half the screen. Why is this, and is there any way to allow me
to make it take up the whole screen? Thanks.
 
F

Family Tree Mike

Change the window properties to 132 columns. The width is probably maxed
out at 80 columns.
 
F

Family Tree Mike

Right click on the console window's title bar and select properties. It
should be on the layout tab, shown as window size.
 
S

Stanimir Stoyanov

In addition to what Mike suggested, you can set the window Width and Height
of your Console at start up:

Console.WindowWidth = Console.LargestWindowWidth
Console.WindowHeight = Console.LargestWindowHeight

This will ensure that your Console takes up the whole working area and is
similar to what PowerShell does.
 
S

sloan

That trick ROCKS!

I altered slightly, to get 90%

Console.WindowWidth = (Console.LargestWindowWidth * 9 / 10);

Console.WindowHeight = (Console.LargestWindowHeight * 9 / 10);



Thanks!!
 
M

Mythran

sloan said:
That trick ROCKS!

I altered slightly, to get 90%

Console.WindowWidth = (Console.LargestWindowWidth * 9 / 10);

Console.WindowHeight = (Console.LargestWindowHeight * 9 / 10);

Or you could have used:

Console.WindowWidth = Console.LargestWindowWidth * 0.9
Console.WindowHeight = Console.LargestWindowHeight * 0.9

:D It's math. Multiple ways to do the same thing :)


hth,
Mythran
 
S

sloan

You should have tested your code dude:

Error 1 Cannot implicitly convert type 'double' to 'int'. An explicit
conversion exists (are you missing a cast?)

That's where I came up with the * 9 / 10 ...
 
M

Michael B. Trausch

Console.WindowWidth = Console.LargestWindowWidth * 0.9
Console.WindowHeight = Console.LargestWindowHeight * 0.9

I think you meant to say:

Console.WindowWidth =
(int)Math.Round((double)Console.LargestWindowWidth*0.9);
Console.WindowHeight =
(int)Math.Round((double)Console.LargestWindowHeight*0.9);

Since Console.Window{Width,Height} are integers. Though, concise this
is not.

Also, it's not very portable; Windows is the only system where the
"console" has any notion of how large it can become on the given
display. Every other operating system uses terminal emulation instead
of a dedicated console, and thus it's maximum width/height is whatever
the user says is going to be, period, so these methods will return the
current size of the terminal on non-Windows systems.

--- Mike
 
M

Michael B. Trausch

Also, it's not very portable; Windows is the only system where the
"console" has any notion of how large it can become on the given
display.

Furthermore (I should have mentioned this in my last post), setting the
Console width and height will throw System.NotSupportedException on
non-Windows platforms, i.e., using Mono. Not sure what Microsoft's
Rotor does on non-Windows platforms, but I suspect it would do the same
thing since there is no way to change the terminal size without the
user doing it manually.

--- Mike
 
M

Mythran

Michael B. Trausch said:
Furthermore (I should have mentioned this in my last post), setting the
Console width and height will throw System.NotSupportedException on
non-Windows platforms, i.e., using Mono. Not sure what Microsoft's
Rotor does on non-Windows platforms, but I suspect it would do the same
thing since there is no way to change the terminal size without the
user doing it manually.

--- Mike

Aye, thanks for the info/correction :)

Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top