Convert console app to Win32 app??

I have this console application, that converts simple words into complex passwords and would like to put it into the form of a basic project and create a UI so that it is more user friendly. I do not know how to convert a console application or re-write it in the proper format that it will work.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Password complexicator
#include <iostream>
#include <fstream>a
#include <stdio.h>     
#include <stdlib.h>     
#include <time.h>
#include <map>
#include <string>

std::map<char, char> myMap{ { 'a','@' },{ 'b','8' },{ 'c','c' },{ 'd','d' },{ 'e','3' },{ 'f','f' },{ 'g','g' },{ 'h','4' },{ 'i','1' },{ 'j','j' },{ 'k','k' },{ 'l','l' },{ 'm','m' },{ 'n','n' },{ 'o','0' },{ 'p','p' },{ 'q','q' },{ 'r','r' },{ 's','$' },{ 't','t' },{ 'u','u' },{ 'v', 'v' },{ 'w','w' },{ 'x','x' },{ 'y','y' },{ 'z','z' },{ 'A','@' },{ 'B','8' },{ 'C','C' },{ 'D','D' },{ 'E','3' },{ 'F','F' },{ 'G','G' },{ 'H','4' },{ 'I','1' },{ 'J','J' },{ 'K','K' },{ 'L','L' },{ 'M','M' },{ 'N','N' },{ 'O','0' },{ 'P','P' },{ 'Q','Q' },{ 'R','R' },{ 'S','$' },{ 'T','T' },{ 'U','U' },{ 'V', 'V' },{ 'W','W' },{ 'X','X' },{ 'Y','Y' },{ 'Z','Z' },{ '1','1' } ,{ '2','2' },{ '3','3' },{ '4','4' },{ '5','5' },{ '6','6' },{ '7','7' },{ '8','8' },{ '9','9' },{ '0','0' }
};
using namespace std;
int main()
{
	system("color 02");
	ofstream out_data("password.txt");
	srand(time(0));
	char a, b, e, h, i, o, s;
	char q[16];
	int r, p;
	r = rand();
	for (p = 01; r <= 29427; p++)
		r = rand();


	cout << "Enter word:" << "\n";
	string line;
	getline(cin, line);
	string cipher{};
	for (auto& elem : line)
	{
		cipher += myMap.find(elem)->second;
	}
	cout << "Your password is: " << "\n" << r << cipher << r << "\n";
	; ;out_data << "Your secure password:" << "\n" << r << cipher << r << "\n";
	cout << "Numbers generated on try " << p << "\n";
	cout << "Type exit to quit \n";
	cin >> q;


	return 0;



	;
}


Last edited on
You are going to need to rewrite your code to avoid main as much as possible. GUI's all take charge of main in some way and there can only be one main. You want most of your code to be written in functions instead. When you start playing with Graphical User Interfaces, things get messy very quickly, the more you can get done with functions, the better.

You will also want to start writing headers to gain access to your functions from other files. Separating out to multiple files is mostly for organization reasons.

There are many GUI's, I prefer to mix and match between Qt and SDL as needed. You might also look into SFML and Alegro, or even windows api, of course the last isn't cross-platform.

I'd suggest you get comfortable with pointers and classes at least before you move outside of console programming though.
Last edited on
Creating a GUI is not an easy task. Even the simplest frameworks have quite a learning curve. If you don't mind have a look at FLTK. What I have seen so far it's probably the easiest. First step would be separate your password logic into a function or maybe a class if you know classes.

http://www.fltk.org/index.php
This is probably overkill for what you're doing, but might give you some ideas. I created a game that runs as both a console app and as a Windows app. The core of the game is written as a DLL. Both the console app and the Windows app share the DLL for the game engine. All presentation is done by the respective app.

Here's a simple example of how this works. The Game class needs to know how many players there are. The Game class is an abstract base class in the DLL. It contains a pure virtual function get_num_players(). get_num_players() is overloaded in both the GameTxt and GameWin classes which derive from Game. GameTxt::get_num_players() does a simple cout/cin to get the number of players. While GameWin::get_num_players() opens a dialog box to select the number of players.


Last edited on
Topic archived. No new replies allowed.