From 66fdf49ed88ba6025ffce328c5a9e508853b6c29 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 7 Mar 2018 15:12:21 +0100 Subject: [PATCH] Work around a Wine bug in wxDateTimePickerCtrl sizing Don't assume that all Vista and later systems support DTM_GETIDEALSIZE, this is not the case under Wine even when it's emulating a Vista+ Windows version and trusting DTM_GETIDEALSIZE to always return the right value resulted in these controls having 0 size and not being shown at all when running wxWidgets programs under Wine. See https://bugs.winehq.org/show_bug.cgi?id=44680 --- src/msw/datetimectrl.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/msw/datetimectrl.cpp b/src/msw/datetimectrl.cpp index 9b8fa66bdf..18eed3d105 100644 --- a/src/msw/datetimectrl.cpp +++ b/src/msw/datetimectrl.cpp @@ -117,11 +117,18 @@ wxSize wxDateTimePickerCtrl::DoGetBestSize() const if ( wxGetWinVersion() >= wxWinVersion_Vista ) { SIZE idealSize; - ::SendMessage(m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)&idealSize); - size = wxSize(idealSize.cx, idealSize.cy); + // Work around https://bugs.winehq.org/show_bug.cgi?id=44680 by + // checking for the return value: even if all "real" MSW systems do + // support this message, Wine does not, even when it's configured to + // return Vista or later version to the application. + if ( ::SendMessage(m_hWnd, DTM_GETIDEALSIZE, 0, (LPARAM)&idealSize) ) + { + size = wxSize(idealSize.cx, idealSize.cy); + } } - else // Windows XP + + if ( !size.x || !size.y ) { wxClientDC dc(const_cast(this));