I made a program similar to Notepad using Visual Studio Community 2017 on Windows 10. It uses edit control created with CreateWindow with the following styles:
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL
| WS_BORDER | ES_LEFT | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL
As you see, there's no DS_LOCALEDIT
.
However, using EM_SETHANDLE or EM_GETHANDLE to access the buffer within the edit control seems to work flawlessly. The following is a snippet of code that does initial buffer allocation for edit control that is supposed to have been created with DS_LOCALEDIT
:
HLOCAL hEditMem = ::LocalAlloc(LPTR, sizeof(wchar_t) * 51);
wchar_t* pszEdit = reinterpret_cast<wchar_t*>(::LocalLock(hEditMem));
const std::wstring strData(L"Hello");
std::char_traits<wchar_t>::copy(pszEdit, strData.c_str(), strData.size());
::SendMessageW(hwndEdit, EM_SETHANDLE, reinterpret_cast<WPARAM>(hEditMem), 0);
::SendMessageW(hwndEdit, EM_SETMODIFY, TRUE, 0);
The documentation here clearly states that:
An application that uses the default allocation behavior (that is, does not use the
DS_LOCALEDIT style must not send EM_SETHANDLE and EM_GETHANDLE messages to the edit
control.
May be someone in Microsoft inconspicuously made the DS_LOCALEDIT
no longer necessary as of Windows 10 or VS 2017 ?