C++ Code ConsoleApp -> WinForms menu

Shout-Out

User Tag List

Results 1 to 12 of 12
  1. #1
    xyfz's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    C++ Code ConsoleApp -> WinForms

    Hey,

    i want to implement some code from my console app to my win form.

    dont know how to write that for loop in win forms though...

    pls help, thanks.

    in console app:

    Code:

    string pw;
    char key;

    cout << "Pw: ";
    cin >> pw;

    cout << "\nKey: ";
    cin >> key;

    for (int i = 0; i < pw.size(); i++)
    {
    pw[i] ^= key;
    }

    C++ Code ConsoleApp -&gt; WinForms
  2. #2
    Cromon's Avatar Legendary


    Reputation
    840
    Join Date
    Mar 2008
    Posts
    714
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, if you use windows forms you are using C++/CLI if you wanna have C++-syntax. Technically IJW lets you mix managed and unmanaged code as it says: "It just works". But im not sure if the standard streams in cout and cin are correctly initialized. However, use Console::ReadLine/WriteLine for cin/cout and String^ instead of std::string.

    Besides that: From your code i guess you are using-namespace-std'ing which is a bad thing. Explictely select objects from the namespace if you are to lazy writing 5 characters before the object. (like using std::string; using std::cout; etc)

  3. #3
    xyfz's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, yeah. thanks for your answer. thats clear.


    String ^pw = txtPw-> Text;
    ...
    ...
    for (int i = 0; i < sizeof(pw); i++)
    {
    here is my problem
    }



    my only problem is the loop.

  4. #4
    Cromon's Avatar Legendary


    Reputation
    840
    Join Date
    Mar 2008
    Posts
    714
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    for(int i = 0; i < pw->Length; ++i) {
        pw[i] ^= key;
    }
    should do the trick.

  5. #5
    xyfz's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Error 1 error C3070: 'System::String::default': property does not have a 'set' method


    Googled it but dont know how to solve this error... Something about converting that string to char and then back to string again..?!

  6. #6
    Cromon's Avatar Legendary


    Reputation
    840
    Join Date
    Mar 2008
    Posts
    714
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea, obviously Strings in .NET are somehow immutable (a good thing!) so you just create a temporary string where you add the crypted values:
    Code:
    String^ pwCpy = gcnew String(L"");
    for(int i = 0; i < pw->Length; ++i)
        pwCpy += pw[i] ^ key;
    
    pw = pwCpy;

  7. #7
    xyfz's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as always, thank you very much for your help cromon!

    it worked now, but its kinda not what i expected.
    like in the console app e.g.

  8. #8
    Cromon's Avatar Legendary


    Reputation
    840
    Join Date
    Mar 2008
    Posts
    714
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its not what you expected because you are no longer using plain C++ but managed (.NET) C++. Therefore a lot of things change.

  9. #9
    xyfz's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what would you suggest for putting my console app in a win forms app? is there any way i can achieve the same results like in my console app?

  10. #10
    Cromon's Avatar Legendary


    Reputation
    840
    Join Date
    Mar 2008
    Posts
    714
    Thanks G/R
    0/7
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, what do you mean with "the same result"? You get the same result in your forms application with the code above. Whats different for you?

  11. #11
    xyfz's Avatar Private
    Reputation
    1
    Join Date
    Oct 2012
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, as you said before; plain c++ and managed c++.

    i will take a look in IJW in managed c++. thanks for that.

  12. #12
    Rokz's Avatar Member
    Reputation
    1
    Join Date
    Jul 2008
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you get your basic Win32 GUI layout first make sure that's running. I'm pretty sure your for loop in fine, just remove your cout and cin and replace them with an edit box each. Once you click the "Login" button or whatever you have, call your for loop to check your entries and all the other stuff you'll need to add in.

Similar Threads

  1. Codes for CE Mountain climb and No damage fall =D
    By FoRbIdDeN in forum World of Warcraft Bots and Programs
    Replies: 23
    Last Post: 10-28-2006, 09:21 AM
  2. I need Current PTR Mountain climbing code-Because of error
    By Wildslayer in forum World of Warcraft General
    Replies: 0
    Last Post: 08-16-2006, 08:24 AM
  3. LOTS of WPE codes
    By Örpheus in forum World of Warcraft Bots and Programs
    Replies: 16
    Last Post: 08-04-2006, 01:19 PM
  4. [Bot:Source] Acidic Bot Source Code
    By =sinister= in forum World of Warcraft Bots and Programs
    Replies: 10
    Last Post: 07-03-2006, 05:38 PM
  5. Error in checking WoW.exe CRC code hack?
    By Trichelieu in forum World of Warcraft General
    Replies: 0
    Last Post: 06-11-2006, 02:24 PM
All times are GMT -5. The time now is 02:37 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search