mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-09-19 20:36:18 +02:00
Windows: Fix EFI configuration editor various issues
We always using Unicode functions to interact with UI. We convert UTF8 string to UTF16 and vis-versa. Overwrite input string instead of using resize that caused old test to remain. Fix case of readOnly by using correct message. change position of OK/cancel button to match other dialogs. Activate translation on this dialog.
This commit is contained in:
parent
aaf42a84a7
commit
68e2e01745
@ -344,9 +344,9 @@ IDD_TEXT_EDIT_DLG DIALOGEX 0, 0, 372, 220
|
|||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
PUSHBUTTON "OK",IDOK,306,201,58,14
|
PUSHBUTTON "OK",IDOK,244,201,58,14
|
||||||
CONTROL "",IDC_INFO_BOX_TEXT,"RichEdit20W",ES_MULTILINE | ES_WANTRETURN | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,5,6,361,188
|
CONTROL "",IDC_INFO_BOX_TEXT,"RichEdit20W",ES_MULTILINE | ES_WANTRETURN | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,5,6,361,188
|
||||||
DEFPUSHBUTTON "Cancel",IDCANCEL,240,201,58,14
|
DEFPUSHBUTTON "Cancel",IDCANCEL,308,201,58,14
|
||||||
END
|
END
|
||||||
|
|
||||||
|
|
||||||
|
@ -4165,6 +4165,7 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
|||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
prm = (TEXT_INFO_DIALOG_PARAM_PTR)lParam;
|
prm = (TEXT_INFO_DIALOG_PARAM_PTR)lParam;
|
||||||
|
LocalizeDialog (hwndDlg, NULL);
|
||||||
// increase size limit of rich edit control
|
// increase size limit of rich edit control
|
||||||
SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_EXLIMITTEXT, 0, -1);
|
SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_EXLIMITTEXT, 0, -1);
|
||||||
|
|
||||||
@ -4175,9 +4176,43 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
|||||||
if (prm->ReadOnly)
|
if (prm->ReadOnly)
|
||||||
{
|
{
|
||||||
// switch rich edit control to ReadOnly
|
// switch rich edit control to ReadOnly
|
||||||
SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), ES_READONLY, TRUE, 0);
|
SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_SETREADONLY , TRUE, 0);
|
||||||
// hide cancel button
|
// hide cancel button
|
||||||
ShowWindow(GetDlgItem(hwndDlg, IDCANCEL), SW_HIDE);
|
HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL);
|
||||||
|
ShowWindow(hwndCancel, SW_HIDE);
|
||||||
|
|
||||||
|
// Reposition OK button to Cancel button's position
|
||||||
|
HWND hwndOK = GetDlgItem(hwndDlg, IDOK);
|
||||||
|
if (hwndOK && hwndCancel)
|
||||||
|
{
|
||||||
|
// Get Cancel button's position in screen coordinates
|
||||||
|
RECT rectCancel;
|
||||||
|
if (GetWindowRect(hwndCancel, &rectCancel))
|
||||||
|
{
|
||||||
|
// Convert Cancel button's position to dialog's client coordinates
|
||||||
|
POINT ptCancel = { rectCancel.left, rectCancel.top };
|
||||||
|
ScreenToClient(hwndDlg, &ptCancel);
|
||||||
|
|
||||||
|
// Get OK button's current size
|
||||||
|
RECT rectOK;
|
||||||
|
if (GetWindowRect(hwndOK, &rectOK))
|
||||||
|
{
|
||||||
|
int width = rectOK.right - rectOK.left;
|
||||||
|
int height = rectOK.bottom - rectOK.top;
|
||||||
|
|
||||||
|
// Move OK button to Cancel button's position
|
||||||
|
SetWindowPos(
|
||||||
|
hwndOK,
|
||||||
|
NULL,
|
||||||
|
ptCancel.x,
|
||||||
|
ptCancel.y,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
SWP_NOZORDER | SWP_NOACTIVATE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMessage (hwndDlg, TC_APPMSG_LOAD_TEXT_BOX_CONTENT, 0, 0);
|
SendMessage (hwndDlg, TC_APPMSG_LOAD_TEXT_BOX_CONTENT, 0, 0);
|
||||||
@ -4189,8 +4224,12 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
if (!prm->ReadOnly)
|
if (!prm->ReadOnly)
|
||||||
{
|
{
|
||||||
prm->Text.resize(GetWindowTextLengthA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT)) + 1);
|
// read content of the text box as UTF16 and then convert it to UTF8
|
||||||
GetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), &(prm->Text)[0], (int) prm->Text.size());
|
HWND hEdit = GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT);
|
||||||
|
int size = GetWindowTextLengthW(hEdit);
|
||||||
|
std::vector<WCHAR> buffer(size + 1);
|
||||||
|
GetWindowTextW(hEdit, buffer.data(), size + 1);
|
||||||
|
prm->Text = WideToUtf8String(buffer.data());
|
||||||
}
|
}
|
||||||
NormalCursor ();
|
NormalCursor ();
|
||||||
EndDialog (hwndDlg, IDOK);
|
EndDialog (hwndDlg, IDOK);
|
||||||
@ -4207,7 +4246,8 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
case TC_APPMSG_LOAD_TEXT_BOX_CONTENT:
|
case TC_APPMSG_LOAD_TEXT_BOX_CONTENT:
|
||||||
{
|
{
|
||||||
SetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), prm->Text.c_str());
|
// convert prm->Text to UTF16 using Utf8StringToWide
|
||||||
|
SetWindowTextW(GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT), Utf8StringToWide(prm->Text).c_str());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user