Click to See Complete Forum and Search --> : start the console in fullscreen mode! and some other newbie questions.
alexandergre
September 8th, 2008, 11:14 AM
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!
eclipsed4utoo
September 8th, 2008, 01:11 PM
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 '*'
Talikag
September 8th, 2008, 03:05 PM
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.
JonnyPoet
September 9th, 2008, 06:08 AM
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.
foamy
September 9th, 2008, 07:08 AM
Taken from msdn:
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("*");
eclipsed4utoo
September 9th, 2008, 07:34 AM
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.
alexandergre
September 9th, 2008, 01:08 PM
Thank you very much foamy! TACK!
jag e från sverige!
thanks guys! :D : D
dahwan
September 9th, 2008, 03:36 PM
alexandergre, "fullscreening" a Console window cannot be done, sorry :)
JonnyPoet
September 9th, 2008, 07:17 PM
alexandergre, "fullscreening" a Console window cannot be done, sorry :)Its Ok. - long ago - People changes :D welcome back
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.