summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/passworddialog.cpp
blob: fac061f2145beb5c897d12217979ae87ac9d270c (plain)
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
50
51
52
53
54
55
56
57
58
59
//fürs passwort dialog - dufte

#include "stdafx.h"
#include "passworddialog.h"

static char nick[255];
BOOL usenick = FALSE;

INT_PTR CALLBACK DlgPWProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static char* pw[255];
	switch (msg)
	{
	case WM_CLOSE:
	{
		GetDlgItemTextA(hwndDlg, IDC_PWSTRING, (LPSTR)pw, 254);
		if (usenick)
			GetDlgItemTextA(hwndDlg, IDC_PWNICK, (LPSTR)nick, _countof(nick));
		EndDialog(hwndDlg, (INT_PTR)pw);
		break;
	}
	case WM_INITDIALOG:
	{
		TranslateDialogDefault(hwndDlg);
		//passwort und nick leeren
		pw[0] = 0;
		nick[0] = 0;
		SendMessage(hwndDlg, WM_SETICON, (WPARAM)false, (LPARAM)LoadIcon(hinstance, MAKEINTRESOURCE(IDI_TM)));
		if (!usenick)
			EnableWindow(GetDlgItem(hwndDlg, IDC_PWNICK), FALSE);

		return TRUE;
	}
	case WM_COMMAND:
	{
		if (LOWORD(wParam) == IDC_BTN4) {
			SendMessage(hwndDlg, WM_CLOSE, 0, 0);
		}
		break;
	}
	}
	return FALSE;
}

void ShowPasswordDialog(char*pw, char*mynick) {
	if (mynick != NULL)
	{
		usenick = TRUE;
	}
	else
		usenick = FALSE;

	char* npw = (char*)DialogBox(hinstance, MAKEINTRESOURCE(IDD_PWDLG), NULL, DlgPWProc);
	mir_strcpy(pw, npw);
	if (mynick)
	{
		mir_strcpy(mynick, (char*)nick);
	}
}