Sign in to follow this  
aaronson2012

How can I make a console app full screen in C#?

Recommended Posts

aaronson2012    101
I'm making an old-school text-based adventure game and I wish to make the console full screen.

This would help in capturing the atmosphere of old games like that, but how can I go about doing this?

Thank you for your reply!

Share this post


Link to post
Share on other sites
signal_    366
First off, I am not a C# master so take this with a grain of salt. Perhaps someone could expand or offer a better solution. It seems like there should be an easy way to do this, but I guess not.

I got this code/discussion from here in case you wanted to read what the others had to say.

Here's some code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
class Program
{
[DllImport("kernel32.dll", ExactSpelling = true)]

private static extern IntPtr GetConsoleWindow();
private static IntPtr ThisConsole = GetConsoleWindow();

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]

private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private const int HIDE = 0;
private const int MAXIMIZE = 3;
private const int MINIMIZE = 6;
private const int RESTORE = 9;

static void Main(string[] args)
{
Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
ShowWindow(ThisConsole, MAXIMIZE);

Console.WriteLine("Hello World in Full Screen!");
Console.ReadLine();
}
}
}





Edit: Forgot to say this is not true full screen and the display height and width would determine the size of the screen so it might not be an acceptable solution....

Share this post


Link to post
Share on other sites
braindigitalis    18902
I am not sure full screen mode is supported any more. To prove this open a command prompt with start->run 'cmd' and press alt-enter. You will get a message 'This system does not support fullscreen mode.' As i have understood from vista onwards this is not supported so anyone beyond XP (which lets face it, is an old and fast-becoming unsupported OS!) won't be able to play your game fullscreen anyway.

You might want to take note that this is a depreciated feature before coding in support for it at all.

Instead you could emulate full screen in XNA with a SpriteFont, or something like that? It would appear like fullscreen but be much wider in compatibility than trying a real text-mode fullscreen.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this