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

Started by
1 comment, last by Brain 13 years, 6 months ago
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!
Advertisement
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....
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.

This topic is closed to new replies.

Advertisement