Results 1 to 12 of 12
  1. #1
    NadeHouse's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Location
    whitespace
    Posts
    337
    Reputation
    55
    Thanks
    2,268
    My Mood
    Daring

    Thumbs up How To Add A Login Screen - C# [In-Depth]

    Let's Jump Right Into It...

    Lets say you already have a fully working program and just want to add it that you need a password to lets say 'Activate' it. Without having to add a seperate form that starts at the begining...

    You could do some thing like this

    Goto your Form1.load and add something like

    button1.Enabled = false;

    And keep doing that till you disable every thing on start up, and then have a textbox and a button that checks if the password is correct then every thing will be re-enabled by doing

    button1.Enabled = true;

    ------------------
    You should be able to know that from doing what I am about to show...
    This is going to be a loginscreen before your program starts


    Start off by adding a Button and a Textbox.

    Lets add a string...

    Code:
    string password;
    Now a bit of this... (Don't worry pictures at the end)

    Code:
    password = textBox1.Text;
    Add that stuff in the button1_Click -> This can be done by double clicking the button...

    Now the first part.. Check if they even bothered to type some thing in

    Code:
    if (password == "")
    {
         MessageBox.Show("Ha you forgot to type in st00f");
    }
    Basically if textbox1 is left blank, prompt this message

    But what if they typed the correct password?

    Code:
    else if (password == "nadehousefortehlulz")
    {
         this.Visible = false;
         Form2 NEXTWINDOW = new Form2();
         NEXTWINDOW.Show();
    }
    What this means is that the password we want them to enter will always be "nadehousefortehlulz" <-- PS this is how you change the password
    and if it is valid we want the login screen to close and move to our next form, in this case Form2

    Hang on.. What if they typed the wrong password?

    Code:
    else
    {
         MessageBox.Show("Ha you are a noob", "Invalid Password")
    }
    This is our last check, if all else fails the program will read this code, and it is saying to show a messagebox saying what ever we put there

    ---

    Wait, I want the password system you used in your trainer, where it closes on the 5th attempt!

    This is simple

    Above our code we will add

    int fail = 1;

    and inside our code when ever they do something wrong add

    fail++;

    This will add a count to fail

    Thus fail = 2 now.
    ----

    How to make the program close on the 5th attempt?

    Add a timer,

    if (fail ==5)
    {
    Application.Exit();
    }


    Now this is the fun part, notice how mine changes colour every time it goes up and the text changes on the label?


    We could add things to the timer such as more if's

    Code:
    if (fail ==4)
    {
       label1.ForeColor = System.Drawing.Color.Translator.FromHtml("#FF0000");
    }
    Hold up you may say, why HTML colours? I used to play a game where you could use HTML codes in your guild announcments so I know a few off by heart soo yeah >.>

    Mess around with this people!

    Show me your screenshots I wanna see what you younge minds can do!

    Now for le picture






  2. The Following User Says Thank You to NadeHouse For This Useful Post:

    Horror (10-30-2012)

  3. #2
    Violence begets violence, so why give it back?
    MPGH Member
    Skinksteek's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    In a Care Package
    Posts
    497
    Reputation
    30
    Thanks
    623
    My Mood
    Angelic
    Thanks Nadehousey! It helped me well.
    Maybe may we chat on skype anytime?

    Skype:
    fablewow_xd
    Made by @Jorndel


    [IMG]https://www.danasof*****m/sig/Trololol132237.jpg[/IMG]


    Leecher: 0 []
    Choob: 25 []
    Newbie: 50 []
    Member: 100 []
    Advanced Member: 150 []
    Dual-Keyboard Member: 250 []
    Expert Member: 500 []
    Bobo's Trainer: 750 [X]
    MPGH Expert: 1000 [X]
    Synthetic Hacker: 1250 [X]
    Blackhat Hacker: 1500 [X]
    Whitehat Hacker: 2000 [X]
    Bobo's Guardian: 2500 [X]
    Upcoming MPGHiean: 3000 [X]
    MPGH Addict: 3500 [X]
    MPGHiean: 4000 [X]
    MPGH Knight: 4500 [X]
    MPGH Lord: 5000 [X]
    MPGH Champion: 5500 [X]
    MPGH King: 6000 [X]
    "Wish me a good luck."

  4. #3
    Horror's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Location
    51,4.
    Posts
    6,920
    Reputation
    574
    Thanks
    5,050
    My Mood
    Twisted
    Usefull, but in this case only one password is the right one, ppl cant create accounts , etc ... So yea, but thats illegal on MPHH anyways ...
     

    Minion+ : February 2014 - January 2015
    Counter Strike: Global Offensive Minion : November 2014 - January 2015
    Alliance of Valiant Arms Minion : August 2014 - January 2015
    Need For Speed World Minion : January 2014 - January 2015
    Rust Minion : January 2014 - January 2015
    Call of Duty Minion : January 2013 - January 2015
    Editor : December 2012 - April 2013
    Donator : March 2014 - Current
    Member : October 2010 - Current

    Previously known as "Isaakske".

  5. #4
    mwxplayer's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    hax
    Posts
    584
    Reputation
    10
    Thanks
    2,928
    My Mood
    Doh
    I already know this and all knows to make a Simple login Screen

  6. #5
    NadeHouse's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Location
    whitespace
    Posts
    337
    Reputation
    55
    Thanks
    2,268
    My Mood
    Daring
    Quote Originally Posted by mwxplayer View Post
    I already know this and all knows to make a Simple login Screen
    Thanks for the put down brew maybe next time il just post a picture of someone flipping you off as the post.





  7. The Following User Says Thank You to NadeHouse For This Useful Post:

    Kenshin13 (10-30-2012)

  8. #6
    Kenshin13's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Cloud 9
    Posts
    3,470
    Reputation
    564
    Thanks
    6,168
    My Mood
    Psychedelic
    Somehow this code looks simpler to me:
    Code:
    
    private int tries = 0;
    private void button1_Click(object sender, EventArgs e)
    {
    	++tries;
    	string password = textBox1.Text;
    	if(password == NULL) MessageBox.Show("Ha you forgot to type in st00f");
    	else 
    		if(password == "nadehousefortehlulz")
    		{
    		   Visible = false;
    		   Form2 NEXTWINDOW = new Form2();
    		   NEXTWINDOW.Show();
    		}
    	else MessageBox.Show("Ha you are a noob", "Invalid Password");
    	if(tries == 5) Application.Exit();
    }
    

  9. #7
    mwxplayer's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    hax
    Posts
    584
    Reputation
    10
    Thanks
    2,928
    My Mood
    Doh
    Quote Originally Posted by NadeHouse View Post
    Thanks for the put down brew maybe next time il just post a picture of someone flipping you off as the post.
    ops not screen but form

  10. #8
    Slendyy's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Location
    Unknown
    Posts
    1,322
    Reputation
    10
    Thanks
    306
    My Mood
    Cool
    Thanks 4 the steps

  11. #9
    Eidolon's Avatar
    Join Date
    Sep 2011
    Gender
    male
    Location
    Vanished
    Posts
    822
    Reputation
    54
    Thanks
    4,077
    My Mood
    Angelic
    .NET fails unless you obfuscate (decompilernoobs are everywhere).
    Nice share for the newbs anyway.

    BTW check this out
    Code:
    .field private string password
    
    .field private int32 tries
    .NET is even recognized in a debugger.
    Its really easy avoiding passwords this way so please don't use this way with any mindblowing info (like MPGH username + password)
    Last edited by Eidolon; 10-30-2012 at 09:46 AM.




    Yet, you are a pathetic human.

    Contributor since: 7.26.2012 - ended
    Donator since: 7.14.2012


  12. The Following User Says Thank You to Eidolon For This Useful Post:

    Jorndel (10-30-2012)

  13. #10
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Here you have an very short code, and easy to use.


    + Instead of making "many" small tutorials.
    Go write a mini-book or so with tutorials
    _____________________________________________


    As said, using this, IS not a good way to make your applications safe.
    It's mainly just one ASM code change, and you have bypassed it. [JE=JUMP IF EQUAL-TO-JNZ=Jump IF NOT EQUAL]

    Or you just read it

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  14. #11
    C4P's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    34
    Reputation
    10
    Thanks
    2
    My Mood
    Happy
    Good job for making this tutorial, might help few people.

  15. The Following User Says Thank You to C4P For This Useful Post:

    NadeHouse (10-30-2012)

  16. #12
    NadeHouse's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Location
    whitespace
    Posts
    337
    Reputation
    55
    Thanks
    2,268
    My Mood
    Daring
    ---------Bump---------





Similar Threads

  1. [Release] How to edit CF Login Screen (Video)
    By ˘hris. in forum CrossFire Mods & Rez Modding
    Replies: 20
    Last Post: 08-05-2011, 04:43 AM
  2. How To Create a Login Screen? (CA)
    By jennajones in forum Programming Tutorial Requests
    Replies: 3
    Last Post: 06-11-2010, 01:02 AM
  3. [Tutorial] How to make a login screen
    By FrostyTheSnowman in forum CrossFire Mods & Rez Modding
    Replies: 5
    Last Post: 06-08-2010, 06:34 AM
  4. [Help] how to make a login screen
    By dsv.13 in forum CrossFire Mods & Rez Modding
    Replies: 7
    Last Post: 04-05-2010, 02:50 AM
  5. How to mod the login screen
    By josephlwu in forum CrossFire Mods & Rez Modding
    Replies: 2
    Last Post: 03-06-2010, 02:18 AM