forked from hrydgard/ppsspp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputBox.cpp
67 lines (59 loc) · 1.32 KB
/
InputBox.cpp
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
60
61
62
63
64
65
66
67
#include <windows.h>
#include "InputBox.h"
#include "Resource.h"
static TCHAR textBoxContents[256];
static TCHAR out[256];
static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case WM_INITDIALOG:
SetWindowText(GetDlgItem(hDlg,IDC_INPUTBOX),textBoxContents);
return TRUE;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
GetWindowText(GetDlgItem(hDlg,IDC_INPUTBOX),out,255);
EndDialog(hDlg,IDOK);
return TRUE;
case IDCANCEL:
EndDialog(hDlg,IDCANCEL);
return TRUE;
}
default:
return FALSE;
}
}
template <bool hex>
void InputBoxFunc()
{
}
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue)
{
if (defaultvalue && strlen(defaultvalue)<255)
strcpy(textBoxContents,defaultvalue);
else
strcpy(textBoxContents,"");
if (IDOK==DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc))
{
strcpy(outvalue,out);
return true;
}
else
return false;
}
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, TCHAR *title, u32 defaultvalue, u32 &outvalue)
{
sprintf(textBoxContents,"%08x",defaultvalue);
INT_PTR value = DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc);
if (value == IDOK)
{
sscanf(out,"%08x",&outvalue);
return true;
}
else
{
out[0]=0;
return false;
}
}