I'm using Visual Studio 2022 on Windows 10.
I have a Rich Edit control that I've created using the following line of code:
editWrap = CreateWindowEx(ES_EX_ZOOMABLE, MSFTEDIT_CLASS, nullptr, ES_MULTILINE | WS_VISIBLE | WS_CHILD | WS_VSCROLL | ES_AUTOVSCROLL | ES_DISABLENOSCROLL, 0, 0, 0, 0, hwnd, nullptr, appInstance, nullptr);
In my WindowProc, I have the following code in a switch case that handles the EN_UPDATE notification from the Rich Edit control:
WPARAM numerator{};
LPARAM denominator{};
if (auto result = SendMessage(getCurrentEditor(), EM_GETZOOM, numerator, denominator); result == TRUE)
{
std::wstringstream messageStream{};
messageStream << result << ": " << LOWORD(numerator) << "/" << LOWORD(denominator) << "\n";
OutputDebugString(messageStream.str().data());
}
When that block of code executes, the SendMessage() call always returns FALSE since the debug string never shows up in the Output pane of Visual Studio. It doesn't matter whether I've zoomed the control using the mouse or using the menu items that I've wired up to programmatically change the zoom ratio.
Is there something I'm missing?
By the way, getCurrentEditor() returns the HWND for the currently active editor. My app has two editors that I switch between based on whether wrapping is enabled or not.
Sorry, when I tested the solution I lazily used the Edit_GetZoom macro which did the casting for me.
Try this -