mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-14 19:17:35 +01:00
InputBox provides cancellation feedback and checks against invalid input; fixed a bug in Properties that reset settings when clicking Cancel in the InputBox; fixed a bug in Properties that corrupted the registry entries when InputBox is unable to launch (#734)
This commit is contained in:
parent
04575c37cd
commit
60f1bac1f1
@ -1829,9 +1829,9 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
}
|
||||
else
|
||||
{
|
||||
WCHAR* wszTitle = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
||||
wchar_t* x = wcschr(ddd + 2, L'"');
|
||||
x[0] = 0;
|
||||
//WCHAR* wszTitle = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
||||
//wchar_t* x = wcschr(ddd + 2, L'"');
|
||||
//x[0] = 0;
|
||||
//wprintf(L">>> %s\n", ddd + 2);
|
||||
}
|
||||
}
|
||||
@ -2359,18 +2359,28 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
DWORD val = 0;
|
||||
if (bInput)
|
||||
{
|
||||
WCHAR* wszAnswer = malloc(MAX_LINE_LENGTH * sizeof(WCHAR));
|
||||
InputBox(FALSE, hwnd, wszPrompt, wszTitle, wszDefault, wszAnswer, MAX_LINE_LENGTH);
|
||||
GUI_RegSetValueExW(
|
||||
hKey,
|
||||
name,
|
||||
0,
|
||||
REG_SZ,
|
||||
wszAnswer,
|
||||
(wcslen(wszAnswer) + 1) * sizeof(WCHAR)
|
||||
);
|
||||
Sleep(100);
|
||||
PostMessageW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), EP_WEATHER_WM_FETCH_DATA, 0, 0);
|
||||
WCHAR* wszAnswer = calloc(MAX_LINE_LENGTH, sizeof(WCHAR));
|
||||
BOOL bWasCancelled = FALSE;
|
||||
if (SUCCEEDED(InputBox(FALSE, hwnd, wszPrompt, wszTitle, wszDefault, wszAnswer, MAX_LINE_LENGTH, &bWasCancelled)) && !bWasCancelled)
|
||||
{
|
||||
if (wszAnswer[0])
|
||||
{
|
||||
GUI_RegSetValueExW(
|
||||
hKey,
|
||||
name,
|
||||
0,
|
||||
REG_SZ,
|
||||
wszAnswer,
|
||||
(wcslen(wszAnswer) + 1) * sizeof(WCHAR)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegDeleteValueW(hKey, name);
|
||||
}
|
||||
Sleep(100);
|
||||
PostMessageW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), EP_WEATHER_WM_FETCH_DATA, 0, 0);
|
||||
}
|
||||
free(wszAnswer);
|
||||
}
|
||||
else if (bChoice || bChoiceLefted)
|
||||
|
@ -1088,10 +1088,15 @@ static LRESULT CALLBACK InputBoxProc(int nCode, WPARAM wParam, LPARAM lParam) {
|
||||
return CallNextHookEx(0, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
HRESULT InputBox(BOOL bPassword, HWND hWnd, LPCWSTR wszPrompt, LPCWSTR wszTitle, LPCWSTR wszDefault, LPCWSTR wszAnswer, DWORD cbAnswer)
|
||||
HRESULT InputBox(BOOL bPassword, HWND hWnd, LPCWSTR wszPrompt, LPCWSTR wszTitle, LPCWSTR wszDefault, LPWSTR wszAnswer, DWORD cbAnswer, BOOL* bCancelled)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!wszPrompt || !wszTitle || !wszDefault || !wszAnswer || !cbAnswer || !bCancelled)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
GUID guidBuffer;
|
||||
hr = getEngineGuid(L".vbs", &guidBuffer);
|
||||
|
||||
@ -1162,11 +1167,23 @@ HRESULT InputBox(BOOL bPassword, HWND hWnd, LPCWSTR wszPrompt, LPCWSTR wszTitle,
|
||||
HideInput = bPassword;
|
||||
hr = pActiveScriptParse->lpVtbl->ParseScriptText(pActiveScriptParse, wszEvaluation2, NULL, NULL, NULL, 0, 0, SCRIPTTEXT_ISEXPRESSION, &result, &ei);
|
||||
|
||||
*bCancelled = (result.vt == VT_EMPTY);
|
||||
|
||||
UnhookWindowsHookEx(hHook);
|
||||
|
||||
free(wszEvaluation2);
|
||||
|
||||
memcpy(wszAnswer, result.bstrVal, cbAnswer * sizeof(WCHAR));
|
||||
if (result.bstrVal)
|
||||
{
|
||||
memcpy(wszAnswer, result.bstrVal, cbAnswer * sizeof(WCHAR));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.vt != VT_EMPTY)
|
||||
{
|
||||
wszAnswer[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VariantClear(&result);
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ char* StrReplaceAllA(const char* s, const char* oldW, const char* newW, int* dwN
|
||||
|
||||
WCHAR* StrReplaceAllW(const WCHAR* s, const WCHAR* oldW, const WCHAR* newW, int* dwNewSize);
|
||||
|
||||
HRESULT InputBox(BOOL bPassword, HWND hWnd, LPCWSTR wszPrompt, LPCWSTR wszTitle, LPCWSTR wszDefault, LPCWSTR wszAnswer, DWORD cbAnswer);
|
||||
HRESULT InputBox(BOOL bPassword, HWND hWnd, LPCWSTR wszPrompt, LPCWSTR wszTitle, LPCWSTR wszDefault, LPWSTR wszAnswer, DWORD cbAnswer, BOOL* bCancelled);
|
||||
|
||||
inline BOOL IsHighContrast()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user