Fix some minor login issues, center login dialog on Windows.

This commit is contained in:
Henrik Rydgård committed 2023-07-11 10:16:58 +02:00
1 parent 41594d319a
commit bf3acd9208
2 files changed
+27 -18

No files matched your search

+16 -15
View File
@@ -2,6 +2,7 @@
#include "Common/CommonWindows.h"
#include "Windows/InputBox.h"
#include "Windows/resource.h"
#include "Windows/W32Util/Misc.h"
#include "Common/Data/Encoding/Utf8.h"
static std::wstring textBoxContents;
@@ -18,34 +19,31 @@ static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPA
case WM_INITDIALOG:
SetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), textBoxContents.c_str());
SetWindowText(hDlg, windowTitle.c_str());
if (defaultSelected == false) PostMessage(GetDlgItem(hDlg,IDC_INPUTBOX),EM_SETSEL,-1,-1);
if (defaultSelected == false)
PostMessage(GetDlgItem(hDlg,IDC_INPUTBOX),EM_SETSEL,-1,-1);
W32Util::CenterWindow(hDlg);
return TRUE;
case WM_COMMAND:
switch (wParam)
{
switch (wParam) {
case IDOK:
{
wchar_t temp[256];
GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, 255);
wchar_t temp[512];
GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, ARRAY_SIZE(temp) - 1);
out = temp;
EndDialog(hDlg, IDOK);
return TRUE;
}
EndDialog(hDlg, IDOK);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
default:
return FALSE;
}
default:
return FALSE;
}
}
template <bool hex>
void InputBoxFunc()
{
}
bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue, bool selected)
{
defaultSelected = selected;
@@ -151,6 +149,7 @@ static INT_PTR CALLBACK UserPasswordBoxFunc(HWND hDlg, UINT message, WPARAM wPar
SetWindowText(hDlg, windowTitle.c_str());
PostMessage(GetDlgItem(hDlg, IDC_INPUTBOX), EM_SETSEL, -1, -1);
PostMessage(GetDlgItem(hDlg, IDC_PASSWORDBOX), EM_SETSEL, -1, -1);
W32Util::CenterWindow(hDlg);
return TRUE;
case WM_COMMAND:
switch (wParam)
@@ -162,12 +161,14 @@ static INT_PTR CALLBACK UserPasswordBoxFunc(HWND hDlg, UINT message, WPARAM wPar
g_userName = ConvertWStringToUTF8(temp);
GetWindowText(GetDlgItem(hDlg, IDC_PASSWORDBOX), temp, 255);
g_passWord = ConvertWStringToUTF8(temp);
EndDialog(hDlg, IDOK);
return TRUE;
}
EndDialog(hDlg, IDOK);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
default:
return FALSE;
}
default:
return FALSE;