1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-08-04 16:30:25 +00:00

Merge pull request #248 from mkilgore/fix-password-inputbox

Fix password handling in _InputBox$ on Windows
This commit is contained in:
Matt Kilgore 2022-11-15 21:04:30 -05:00 committed by GitHub
commit bd6ad5fde6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1299,6 +1299,18 @@ static LRESULT displayInputBox(HINSTANCE hinst, HWND hwndOwner, const wchar_t *t
LPWSTR lpwsz;
LRESULT ret;
int nchar;
int isPassword = 0;
if (!title)
title = L"";
if (!lpszMessage)
lpszMessage = L"";
if (!defaultText) {
isPassword = 1;
defaultText = L"";
}
// The extra 500 accounts for the default button text, alignment padding, and a few other small things
hgbl = GlobalAlloc(GMEM_ZEROINIT, sizeof(DLGTEMPLATE)
@ -1343,7 +1355,7 @@ static LRESULT displayInputBox(HINSTANCE hinst, HWND hwndOwner, const wchar_t *t
lpdit->id = ID_TEXT; // Text identifier
lpdit->style = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL | ES_LEFT;
if (wcslen(defaultText) == 0)
if (isPassword)
lpdit->style |= ES_PASSWORD;
lpw = (LPWORD)(lpdit + 1);
@ -1431,10 +1443,6 @@ wchar_t * tinyfd_inputBoxW(
memset(dialogContents, 0, sizeof(dialogContents));
aTitle = aTitle? aTitle: L"";
aMessage = aMessage? aMessage: L"";
aDefaultInput = aDefaultInput? aDefaultInput: L"";
displayInputBox(GetModuleHandle(NULL), GetDialogWindow(), aTitle, aMessage, aDefaultInput);
mbstowcs(lBuff, dialogContents, MAX_PATH_OR_CMD);