mirror of
https://github.com/libretro/ppsspp.git
synced 2024-12-05 07:27:02 +00:00
95 lines
2.0 KiB
C++
95 lines
2.0 KiB
C++
#include "Common/CommonWindows.h"
|
|
#include "Windows/InputBox.h"
|
|
#include "Windows/resource.h"
|
|
|
|
static TCHAR textBoxContents[256];
|
|
static TCHAR out[256];
|
|
static TCHAR windowTitle[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);
|
|
SetWindowText(hDlg, windowTitle);
|
|
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_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength)
|
|
{
|
|
const char *defaultTitle = "Input value";
|
|
|
|
if (defaultvalue && strlen(defaultvalue)<255)
|
|
strcpy(textBoxContents,defaultvalue);
|
|
else
|
|
strcpy(textBoxContents,"");
|
|
|
|
|
|
if(title && strlen(title) <= 0)
|
|
strcpy(windowTitle, defaultTitle);
|
|
else if(title && strlen(title) < 255)
|
|
strcpy(windowTitle, title);
|
|
else
|
|
strcpy(windowTitle, defaultTitle);
|
|
|
|
if (IDOK==DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc))
|
|
{
|
|
strncpy(outvalue, out, outlength);
|
|
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;
|
|
}
|
|
} |