CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2008
    Posts
    13

    start the console in fullscreen mode! and some other newbie questions.

    Hi, Im new here. Call me alexandergre and Im 17 from Sweden. Natural-science student. We are programming with C# but only with console apps (just for now)


    My questions:
    1.A code which makes the console run in fullscreen. I have played around with SetWindowsSize but didnt succeed to make it fullscreen!

    2.
    Console.Write("Password: ");
    string pass = Console.ReadLine();
    I dont want the password to be visible when Im typing it! I want it to be stars or dots!

    thank you very much!
    / this is not a homework. I am just extra working on a project for my self!

  2. #2
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: start the console in fullscreen mode! and some other newbie questions.

    1. you can make the size of the console window equal to the size of the screen. Use the System.Windows.Forms.Screen class.
    2. you can catch each character that is typed, store it, and replace it on the screen with a '*'

  3. #3
    Join Date
    Jan 2007
    Posts
    491

    Re: start the console in fullscreen mode! and some other newbie questions.

    Quote Originally Posted by eclipsed4utoo
    1. you can make the size of the console window equal to the size of the screen. Use the System.Windows.Forms.Screen class.
    2. you can catch each character that is typed, store it, and replace it on the screen with a '*'
    System.Windows.Forms.Screen is for windows application. You can use the Console.Width and Console.Height properties instead.

  4. #4
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: start the console in fullscreen mode! and some other newbie questions.

    Using Console.Readline you will not get your input hidden. I never tried to do this in a Console application, this is normally done in Windows.forms application. Maybe you can use something which catches every single sign. Last time I did this was 30 years ago in an old non windows C application There we used getch as much as I remember. Maybe this is still working ? Then we overwrite the output with an asterix. This was quick enough to net be seen on the screen.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  5. #5
    Join Date
    May 2007
    Location
    Denmark
    Posts
    623

    Re: start the console in fullscreen mode! and some other newbie questions.

    Taken from msdn:

    Code:
    Console.WriteLine("   Enter username:");
        string username = Console.ReadLine();
        Console.WriteLine("   Enter password:");
        string password = "";
        ConsoleKeyInfo info = Console.ReadKey(true);
        while (info.Key != ConsoleKey.Enter)
        {
            if (info.Key != ConsoleKey.Backspace)
            {
                password += info.KeyChar;
                info = Console.ReadKey(true);
            }
            else if (info.Key == ConsoleKey.Backspace)
            {
                if (!string.IsNullOrEmpty(password))
                {
                    password = password.Substring
                    (0, password.Length - 1);
                }
                info = Console.ReadKey(true);
           }
        }
        for (int i = 0; i < password.Length; i++)
        Console.Write("*");
    It's not a bug, it's a feature!

  6. #6
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: start the console in fullscreen mode! and some other newbie questions.

    Quote Originally Posted by Talikag
    System.Windows.Forms.Screen is for windows application. You can use the Console.Width and Console.Height properties instead.
    aren't Console.Width and Console.Height the size of the console window? I was telling him that he could use System.Windows.Forms.Screen to get the height and width of the client screen, then set the height and width of the console window to those values.

  7. #7
    Join Date
    Sep 2008
    Posts
    13

    Re: start the console in fullscreen mode! and some other newbie questions.

    Thank you very much foamy! TACK!
    jag e från sverige!
    thanks guys! : D

  8. #8
    Join Date
    Mar 2007
    Posts
    375

    Re: start the console in fullscreen mode! and some other newbie questions.

    alexandergre, "fullscreening" a Console window cannot be done, sorry
    Last edited by dahwan; September 9th, 2008 at 03:38 PM.
    Please vote the posts you find usefull.

    ---

    I'm back
    Bigger and badder
    Better and bolder
    Explaining stuff -
    With an improved vocabulary!

  9. #9
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: start the console in fullscreen mode! and some other newbie questions.

    Quote Originally Posted by dahwan
    alexandergre, "fullscreening" a Console window cannot be done, sorry
    Its Ok. - long ago - People changes welcome back
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured