ppsspp/Windows/InputBox.cpp
Unknown W. Brackets 97098f109a Use CommonWindows.h from Windows/ too.
Might as well.  Everything still builds fine.
2013-07-28 21:04:20 -07:00

67 lines
1.3 KiB
C++

#include "Common/CommonWindows.h"
#include "Windows/InputBox.h"
#include "Windows/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;
}
}