From d970c8eeae7e86babcad4fac757ad6a18ad73f7a Mon Sep 17 00:00:00 2001 From: Bill Su Date: Fri, 26 May 2023 12:26:08 -0400 Subject: [PATCH 1/4] samples/mfc: needs #define UNICODE The header-order workaround for WINVER should also be used for UNICODE and _UNICODE --- samples/mfc/mfctest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index c46d7e9ec6..8d66561162 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -55,6 +55,12 @@ #ifndef WINVER #define WINVER 0x0600 #endif +#ifndef _UNICODE +# define _UNICODE +#endif +#ifndef UNICODE +# define UNICODE +#endif #include "stdafx.h" From 6b1683757f7adc713985276991d7f98260d01630 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Fri, 26 May 2023 12:55:29 -0400 Subject: [PATCH 2/4] samples/mfc: building with UNICODE requires wide strings --- samples/mfc/mfctest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index 8d66561162..a63f85ca91 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -177,9 +177,9 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, char *, int) CMainWindow::CMainWindow() { - LoadAccelTable( "MainAccelTable" ); - Create( nullptr, "Hello Foundation Application", - WS_OVERLAPPEDWINDOW, rectDefault, nullptr, "MainMenu" ); + LoadAccelTable( L"MainAccelTable" ); + Create( nullptr, L"Hello Foundation Application", + WS_OVERLAPPEDWINDOW, rectDefault, nullptr, L"MainMenu" ); // Create a container representing the MFC window in wxWidgets window // hierarchy. @@ -210,7 +210,7 @@ void CMainWindow::OnPaint() void CMainWindow::OnAbout() { - CDialog about( "AboutBox", this ); + CDialog about( L"AboutBox", this ); about.DoModal(); } From 6ab144f9bf2c329e8d105e7461f8d2d48c6cb7a6 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Fri, 26 May 2023 13:19:06 -0400 Subject: [PATCH 3/4] samples/mfc: disable composition to allow wxClientDC to work --- samples/mfc/mfctest.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index a63f85ca91..1bc447dae4 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -297,6 +297,7 @@ wxEND_EVENT_TABLE() MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size) : wxScrolledWindow(parent, -1, pos, size) { + MSWDisableComposited(); } // Define the repainting behaviour From 7420ab1b2634a5c5a78d0c32af0ac6768a849892 Mon Sep 17 00:00:00 2001 From: Bill Su Date: Sun, 11 Jun 2023 01:50:01 -0400 Subject: [PATCH 4/4] wxMFCApp::PreTranslateMessage: Give msg to MFC before wxWidgets because wxWidgets wxGUIEventLoop::PreProcessMessage() seems to always report that it has consumed msg. fix #23574 --- include/wx/msw/mfc.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/wx/msw/mfc.h b/include/wx/msw/mfc.h index e76701c5a3..b3e4636c35 100644 --- a/include/wx/msw/mfc.h +++ b/include/wx/msw/mfc.h @@ -94,6 +94,12 @@ public: // Override this to provide messages pre-processing for wxWidgets windows. BOOL PreTranslateMessage(MSG *msg) override { + // As reported in issue #23574, wxGUIEventLoop::PreProcessMessage() + // is always returning true, so try BaseApp::PreTranslateMessage() + // and hope it doesn't always report true + if (BaseApp::PreTranslateMessage(msg)) + return TRUE; + // Use the current event loop if there is one, or just fall back to the // standard one otherwise, but make sure we pre-process messages in any // case as otherwise many things would break (e.g. keyboard @@ -103,10 +109,7 @@ public: wxGUIEventLoop evtLoopStd; if ( !evtLoop ) evtLoop = &evtLoopStd; - if ( evtLoop->PreProcessMessage(msg) ) - return TRUE; - - return BaseApp::PreTranslateMessage(msg); + return evtLoop->PreProcessMessage(msg); } BOOL OnIdle(LONG lCount) override