1
#include "Common/CommonWindows.h"
2
#include "Windows/InputBox.h"
3
#include "Windows/resource.h"
4
#include "util/text/utf8.h"
6
static std::wstring textBoxContents;
7
static std::wstring out;
8
static std::wstring windowTitle;
9
static bool defaultSelected;
11
static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
15
SetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), textBoxContents.c_str());
16
SetWindowText(hDlg, windowTitle.c_str());
17
if (defaultSelected == false) PostMessage(GetDlgItem(hDlg,IDC_INPUTBOX),EM_SETSEL,-1,-1);
25
GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, 255);
28
EndDialog(hDlg, IDOK);
31
EndDialog(hDlg, IDCANCEL);
45
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue, bool selected)
47
defaultSelected = selected;
48
if (defaultValue.size() < 255)
49
textBoxContents = ConvertUTF8ToWString(defaultValue);
51
textBoxContents = L"";
58
if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) {
59
outvalue = ConvertWStringToUTF8(out);
66
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue)
68
const wchar_t *defaultTitle = L"Input value";
69
defaultSelected = true;
71
textBoxContents = ConvertUTF8ToWString(defaultValue);
73
if (title && wcslen(title) <= 0)
74
windowTitle = defaultTitle;
75
else if (title && wcslen(title) < 255)
78
windowTitle = defaultTitle;
80
if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) {
81
outvalue = ConvertWStringToUTF8(out);
88
bool InputBox_GetWString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::wstring &defaultValue, std::wstring &outvalue)
90
const wchar_t *defaultTitle = L"Input value";
91
defaultSelected = true;
93
textBoxContents = defaultValue;
95
if (title && wcslen(title) <= 0)
96
windowTitle = defaultTitle;
97
else if (title && wcslen(title) < 255)
100
windowTitle = defaultTitle;
102
if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) {
110
bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, const wchar_t *title, u32 defaultvalue, u32 &outvalue)
113
wsprintf(temp,L"%08x",defaultvalue);
114
textBoxContents = temp;
116
INT_PTR value = DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc);
120
if (swscanf(out.c_str(), L"0x%08x", &outvalue) == 1)
122
if (swscanf(out.c_str(), L"%08x", &outvalue) == 1)
b'\\ No newline at end of file'