Fix pasting for EditNumber32 textboxes

This commit is contained in:
shygoo 2020-06-14 03:04:41 -05:00
parent 32fe7b7672
commit f82ee04173
1 changed files with 8 additions and 8 deletions

View File

@ -97,11 +97,11 @@ void CEditNumber32::FormatClipboard()
{ {
LPTSTR lptstr, lptstrCopy; LPTSTR lptstr, lptstrCopy;
HGLOBAL hglb; HGLOBAL hglb;
if (!this->OpenClipboard() || !IsClipboardFormatAvailable(CF_TEXT)) if (!this->OpenClipboard() || !IsClipboardFormatAvailable(CF_UNICODETEXT))
{ {
return; return;
} }
hglb = GetClipboardData(CF_TEXT); hglb = GetClipboardData(CF_UNICODETEXT);
if (hglb != NULL) if (hglb != NULL)
{ {
lptstr = (LPTSTR)GlobalLock(hglb); lptstr = (LPTSTR)GlobalLock(hglb);
@ -127,10 +127,10 @@ void CEditNumber32::FormatClipboard()
return; return;
} }
lptstrCopy = (LPTSTR)GlobalLock(hglb); lptstrCopy = (LPTSTR)GlobalLock(hglb);
memcpy(lptstrCopy, lptstr, wcslen(lptstr) + 1); memcpy(lptstrCopy, lptstr, (wcslen(lptstr) + 1) * sizeof(TCHAR));
GlobalUnlock(lptstr); GlobalUnlock(lptstr);
GlobalUnlock(hglb); GlobalUnlock(hglb);
SetClipboardData(CF_TEXT, hglb); SetClipboardData(CF_UNICODETEXT, hglb);
CloseClipboard(); CloseClipboard();
} }
} }
@ -146,7 +146,7 @@ LRESULT CEditNumber32::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam
//Paste //Paste
bHandled = false; bHandled = false;
if (!IsClipboardFormatAvailable(CF_TEXT)) if (!IsClipboardFormatAvailable(CF_UNICODETEXT))
{ {
bHandled = true; bHandled = true;
return true; return true;
@ -157,7 +157,7 @@ LRESULT CEditNumber32::OnPaste(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam
return true; return true;
} }
HGLOBAL hglb = GetClipboardData(CF_TEXT); HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
if (hglb != NULL) if (hglb != NULL)
{ {
LPTSTR lptstr = (LPTSTR)GlobalLock(hglb); LPTSTR lptstr = (LPTSTR)GlobalLock(hglb);
@ -181,7 +181,7 @@ LRESULT CEditNumber32::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
int start, end; int start, end;
GetSel(start, end); GetSel(start, end);
wchar_t WindowText[200]; wchar_t WindowText[200];
GetWindowText(WindowText, sizeof(WindowText)); GetWindowText(WindowText, sizeof(WindowText) / sizeof(WindowText[0]));
size_t Len = wcslen(WindowText); size_t Len = wcslen(WindowText);
wchar_t head = Len > 0 ? WindowText[0] : 0; wchar_t head = Len > 0 ? WindowText[0] : 0;
@ -283,7 +283,7 @@ void CEditNumber32::SetDisplayType(DisplayType Type)
uint32_t CEditNumber32::GetValue(void) uint32_t CEditNumber32::GetValue(void)
{ {
wchar_t text[200]; wchar_t text[200];
GetWindowText(text, sizeof(text)); GetWindowText(text, sizeof(text) / sizeof(text[0]));
if (m_DisplayType == DisplayDec) if (m_DisplayType == DisplayDec)
{ {
return _wtoi(text); return _wtoi(text);