Merge branch 'samples-mfc-update' of https://github.com/wsu-cb/wxWidgets

Fix build and behaviour of the MFC sample.

See #23574.
This commit is contained in:
Vadim Zeitlin 2023-06-16 00:02:43 +02:00
commit f50fb719e8
2 changed files with 18 additions and 8 deletions

View file

@ -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

View file

@ -55,6 +55,12 @@
#ifndef WINVER
#define WINVER 0x0600
#endif
#ifndef _UNICODE
# define _UNICODE
#endif
#ifndef UNICODE
# define UNICODE
#endif
#include "stdafx.h"
@ -171,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.
@ -204,7 +210,7 @@ void CMainWindow::OnPaint()
void CMainWindow::OnAbout()
{
CDialog about( "AboutBox", this );
CDialog about( L"AboutBox", this );
about.DoModal();
}
@ -291,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