Remove Windows XP and Vista support

Supporting XP requires too many hacks, and while it wouldn't be very
difficult to support Vista as long as we support Windows 7, it's still
not worth it because nobody uses this system anyhow.

Remove most of XP-specific code and don't use wxDynamicLibrary for using
the functions not present in it any longer.

Don't use <wspiapi.h> neither as we shouldn't use it any more.

Update some comments to not mention Windows versions not supported any
longer and also remove mentions of "Vista and newer Windows versions"
from the documentation as this is now always the case.

This commit is best viewed ignoring whitespace-only changes.
This commit is contained in:
Vadim Zeitlin 2022-11-10 21:33:22 +00:00
parent d761ba0f8f
commit 43ff845e77
49 changed files with 273 additions and 676 deletions

View file

@ -29,7 +29,7 @@ Platforms
This version of wxWidgets supports the following primary platforms:
- Windows XP, Vista, 7, 8, 10 and 11 (32/64 bits).
- Windows 7, 8, 10 and 11 (32/64 bits).
- Most Unix variants using the GTK+ toolkit (version 2.6 or newer or 3.x).
- macOS (10.10 or newer) using Cocoa under both amd64 and ARM platforms.
@ -40,7 +40,7 @@ All C++11 compilers are supported including but not limited to:
- Clang (up to 14).
Please use [3.2 branch](https://github.com/wxWidgets/wxWidgets/tree/3.2) if
you must use wxWidgets with a C++98 compiler.
you must use wxWidgets with a C++98 compiler or support Windows XP.
Licence

View file

@ -79,10 +79,9 @@ paragraphs, but here are some of the benefits:
wxWidgets first-tier "ports", ie implementations of wxWidgets API, are:
@li wxMSW: This is the native port for Microsoft Windows systems (from Windows
XP up to Windows 11), either 32 or 64 bits. The primarily supported compilers
are Microsoft Visual C++ (versions 2005 up to 2022 are supported, at least 2010
is recommended) and GNU g++ (either from the traditional MinGW, TDM-GCC or
MinGW-w64 distributions).
7 up to Windows 11), either 32 or 64 bits. The primarily supported compilers
are Microsoft Visual C++ (versions 2015 up to 2022 are supported) and GNU g++
(either MinGW-w64 or TDM-GCC).
@li wxGTK: wxGTK2 and wxGTK3 are the ports using GTK+ library version 2.x and
3.x respectively. They are very similar, with wxGTK2 being, however, more

View file

@ -81,8 +81,8 @@ In order to configure wxWidgets to compile wxX11 you will need to type:
@section page_port_wxmsw wxMSW
wxMSW is a port of wxWidgets for the Windows platforms (Windows XP and later
are supported). wxMSW provides native look and feel for each Windows version.
wxMSW is a port of wxWidgets for the Windows platforms (current version
requires Windows 7 or later). wxMSW provides native look and feel for each Windows version.
This port can be compiled with several compilers including Microsoft
VC++ 2015 or later, MinGW, Cygwin as well as cross-compilation with a
Linux-hosted MinGW tool chain.

View file

@ -1,7 +1,7 @@
Installing wxWidgets for Windows {#plat_msw_install}
--------------------------------
This is wxWidgets for Microsoft Windows (XP, Vista, 7, 8, 10, 11)
This is wxWidgets for Microsoft Windows 7 or later (up to 11)
including both 32 bit and 64 bit versions.
[TOC]

View file

@ -47,7 +47,7 @@ Supported Platforms
This version of wxWidgets supports the following primary platforms:
* Windows XP, Vista, 7, 8, 10 and 11 (32/64 bits).
* Windows 7, 8, 10 and 11 (32/64 bits).
* Most Unix variants using the GTK+ toolkit (version 2.6 or newer)
* macOS (10.10 or newer) using Cocoa (x86-64 or ARM).

View file

@ -29,8 +29,7 @@ public:
wxButtonBase() { }
// show the authentication needed symbol on the button: this is currently
// only implemented on Windows Vista and newer (on which it shows the UAC
// shield symbol)
// only implemented in wxMSW where it shows the UAC shield symbol
void SetAuthNeeded(bool show = true) { DoSetAuthNeeded(show); }
bool GetAuthNeeded() const { return DoGetAuthNeeded(); }

View file

@ -80,7 +80,7 @@ enum
wxCC_BUTTON_STAYS_DOWN = 0x0008,
// Drop-button covers the entire control.
wxCC_FULL_BUTTON = 0x0010,
// Drop-button goes over the custom-border (used under WinVista).
// Drop-button goes over the custom-border (used under Windows).
wxCC_BUTTON_COVERS_BORDER = 0x0020,
// Internal use: signals creation is complete

View file

@ -336,9 +336,9 @@ public:
#ifdef __WINDOWS__
// return the handle (HMODULE/HINSTANCE) of the DLL with the given name
// and/or containing the specified address: for XP and later systems only
// the address is used and the name is ignored but for the previous systems
// only the name (which may be either a full path to the DLL or just its
// and/or containing the specified address: if a valid address is
// specified, it is used and then name is ignored, but if the address is
// null, the name (which may be either a full path to the DLL or just its
// base name, possibly even without extension) is used
//
// the returned handle reference count is not incremented so it doesn't

View file

@ -68,7 +68,7 @@ protected:
// Switches button into owner-drawn mode: this is used if we need to draw
// something not supported by the native control, such as using non default
// colours or a bitmap on pre-XP systems.
// colours or font.
void MakeOwnerDrawn();
bool IsOwnerDrawn() const;

View file

@ -121,11 +121,6 @@ public:
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const override;
#if wxUSE_UXTHEME
// override wxTextEntry method to work around Windows bug
virtual bool SetHint(const wxString& hint) override;
#endif // wxUSE_UXTHEME
virtual void SetLayoutDirection(wxLayoutDirection dir) override;
virtual const wxTextEntry* WXGetTextEntry() const override { return this; }

View file

@ -27,8 +27,8 @@ public:
virtual int ShowModal() override;
private:
// The real implementations of ShowModal(), used for Windows versions
// before and since Vista.
// The real implementations of ShowModal(), one using the traditional shell
// function and another one using IFileOpenDialog.
int ShowSHBrowseForFolder(WXHWND owner);
int ShowIFileOpenDialog(WXHWND owner);

View file

@ -15,13 +15,10 @@
// We want to use IFileDialog if either wxDirDialog or wxFileDialog are used.
//
// IFileOpenDialog implementation needs wxDynamicLibrary for
// run-time linking SHCreateItemFromParsingName(), available
// only under Windows Vista and newer.
// It also needs a compiler providing declarations and definitions
// of interfaces available in Windows Vista.
// Using IFileOpenDialog requires a compiler providing declarations and
// definitions of interfaces available in Windows Vista.
// And it needs OLE support to actually use these interfaces.
#if (wxUSE_DIRDLG || wxUSE_FILEDLG) && wxUSE_DYNLIB_CLASS && wxUSE_OLE && \
#if (wxUSE_DIRDLG || wxUSE_FILEDLG) && wxUSE_OLE && \
defined(__IFileOpenDialog_INTERFACE_DEFINED__)
#define wxUSE_IFILEOPENDIALOG 1
#else

View file

@ -31,22 +31,7 @@ inline const NONCLIENTMETRICS GetNonClientMetrics(const wxWindow* win)
0,
win) )
{
#if WINVER >= 0x0600
// a new field has been added to NONCLIENTMETRICS under Vista, so
// the call to SystemParametersInfo() fails if we use the struct
// size incorporating this new value on an older system -- retry
// without it
nm.cbSize -= sizeof(int);
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS),
&nm,
0,
win) )
#endif // WINVER >= 0x0600
{
// maybe we should initialize the struct with some defaults?
wxLogLastError(wxT("SystemParametersInfo(SPI_GETNONCLIENTMETRICS)"));
}
wxLogLastError(wxT("SystemParametersInfo(SPI_GETNONCLIENTMETRICS)"));
}
return nm;

View file

@ -168,8 +168,7 @@ public:
Returns @true if an authentication needed symbol is displayed on the
button.
@remarks This method always returns @false if the platform is not
Windows Vista or newer.
@remarks This method always returns @false on non-Windows platforms.
@see SetAuthNeeded()
@ -200,8 +199,7 @@ public:
Sets whether an authentication needed symbol should be displayed on the
button.
@remarks This method doesn't do anything if the platform is not Windows
Vista or newer.
@remarks This method doesn't do anything on non-Windows platforms.
@see GetAuthNeeded()

View file

@ -31,9 +31,8 @@
wxCommandLinkButton generates the same event as wxButton but doesn't
support any of wxButton-specific styles nor adds any new styles of its own.
Currently this class uses native implementation under Windows Vista and
later versions and a generic implementation for the other platforms and
earlier Windows versions.
Currently this class uses native implementation under Windows and a generic
implementation for the other platforms.
@since 2.9.2

View file

@ -60,10 +60,9 @@ const char wxMessageBoxCaptionStr[] = "Message";
@style{wxICON_QUESTION}
Displays a question mark symbol. This icon is automatically used
with @c wxYES_NO so it's usually unnecessary to specify it explicitly.
This style is not supported for message dialogs under wxMSW when a task
dialog is used to implement them (i.e. when running under Windows Vista
or later) because <a href="https://docs.microsoft.com/en-us/windows/desktop/uxguide/mess-confirm">Microsoft
guidelines</a> indicate that no icon should be used for routine
This style is not supported for message dialogs under wxMSW
because <a href="https://docs.microsoft.com/en-us/windows/desktop/uxguide/mess-confirm">Microsoft guidelines</a>
indicate that no icon should be used for routine
confirmations. If it is specified, no icon will be displayed.
@style{wxICON_INFORMATION}
Displays an information symbol. This icon is used by default if
@ -75,8 +74,7 @@ const char wxMessageBoxCaptionStr[] = "Message";
Alias for @c wxICON_ERROR.
@style{wxICON_AUTH_NEEDED}
Displays an authentication needed symbol. This style is only supported
for message dialogs under wxMSW when a task dialog is used to implement
them (i.e. when running under Windows Vista or later). In other cases
for message dialogs under wxMSW. In other cases
the default icon selection logic will be used. Note this can be
combined with other styles to provide a fallback. For instance, using
wxICON_AUTH_NEEDED | wxICON_QUESTION will show a shield symbol on

View file

@ -15,9 +15,8 @@
extra explanatory text which is initially collapsed and not shown to the
user but can be expanded to show more information.
Notice that currently the native dialog is used only under MSW when using
Vista or later Windows version. Elsewhere, or for older versions of
Windows, a generic implementation which is less familiar to the users is
Notice that currently the native dialog is used only under MSW. Elsewhere,
a generic implementation which is less familiar to the users is
used. Because of this it's recommended to use this class only if you do
need its extra functionality and use wxMessageDialog which does have native
implementation under all platforms otherwise. However if you do need to put

View file

@ -102,7 +102,7 @@ public:
Example return values:
- Unix/Mac: @c ~/Downloads
- Windows: @c "C:\Users\username\Downloads" (Only available on Vista and newer)
- Windows: @c "C:\Users\username\Downloads"
*/
Dir_Downloads,

View file

@ -10,10 +10,10 @@
/**
A helper class making it possible to use system theme for any control.
Under MSW, there an alternative theme available for the list and list-like
controls since Windows Vista. This theme us used by Windows Explorer list
and tree view and so is arguably more familiar to the users than the standard
appearance of these controls.
Under MSW, there is an alternative theme available for the list and list-like
controls. This theme is used by Windows Explorer list and tree view and so
is arguably more familiar to the users than the standard appearance of these
controls.
This class is used in wxWidgets to enable this system theme in wxTreeCtrl,
wxListCtrl and wxDataViewCtrl and thus give them the same, familiar look.

View file

@ -463,8 +463,8 @@ public:
Notice that hints are known as <em>cue banners</em> under MSW or
<em>placeholder strings</em> under macOS.
@remarks Currently implemented natively on Windows (Vista and later
only), macOS and GTK+ (3.2 and later).
@remarks Currently implemented natively on Windows, macOS and GTK+ (3.2
and later).
For the platforms without native hints support, the implementation
has several known limitations. Notably, the hint display will not

View file

@ -95,8 +95,8 @@ public:
The language is determined from the preferred UI language or languages
list the user configured in the OS. Notice that this may or may not
correspond to the default @em locale as obtained from
wxLocale::GetSystemLanguage(); modern operation systems (Windows
Vista+, macOS) have separate language and regional (= locale) settings.
wxLocale::GetSystemLanguage() as operating systems have separate
language and regional (i.e. locale) settings.
@param domain
The catalog domain to look for.
@ -118,8 +118,8 @@ public:
The language is determined from the preferred UI language or languages
list the user configured in the OS. Notice that this may or may not
correspond to the default @em locale as obtained from
wxLocale::GetSystemLanguage(); modern operation systems (Windows
Vista+, macOS) have separate language and regional (= locale) settings.
wxLocale::GetSystemLanguage() as operating systems have separate
language and regional (i.e. locale) settings.
@param domain
The catalog domain to look for.

View file

@ -56,7 +56,7 @@
@style{wxTR_TWIST_BUTTONS}
Selects alternative style of @c +/@c - buttons and shows rotating
("twisting") arrows instead. Currently this style is only implemented
under Microsoft Windows Vista and later Windows versions and is ignored
in wxMSW and is ignored
under the other platforms as enabling it is equivalent to using
wxSystemThemedControl::EnableSystemTheme().
@style{wxTR_NO_LINES}

View file

@ -228,12 +228,8 @@ void wxAuiMSWTabArt::DrawTab(wxDC& dc,
else
btnState = TTCS_NORMAL;
int offsetY = tabY;
if ( wxGetWinVersion() < wxWinVersion_Vista )
offsetY++; // WinXP theme needs a little more padding
wxRect rect(tabX + tabWidth - m_closeBtnSize.x - wnd->FromDIP(4),
offsetY + (tabHeight / 2) - (m_closeBtnSize.y / 2),
tabY + (tabHeight / 2) - (m_closeBtnSize.y / 2),
m_closeBtnSize.x,
m_closeBtnSize.y);

View file

@ -88,21 +88,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress);
#define wxHAS_MT_SAFE_GETBY_FUNCS
#if wxUSE_IPV6
#ifdef __VISUALC__
// this header does dynamic dispatching of getaddrinfo/freeaddrinfo()
// by implementing them in its own code if the system versions are
// not available (as is the case for anything < XP)
#pragma warning(push)
#pragma warning(disable:4706)
#include <wspiapi.h>
#pragma warning(pop)
#else
// TODO: Use wxDynamicLibrary to bind to these functions
// dynamically on older Windows systems, currently a program
// built with wxUSE_IPV6==1 won't even start there, even if
// it doesn't actually use the socket stuff.
#include <ws2tcpip.h>
#endif
#include <ws2tcpip.h>
#endif
#endif // __WINDOWS__

View file

@ -2522,14 +2522,8 @@ public:
// wouldn't work if reading an incomplete MB char didn't result in an
// error
//
// Moreover, MB_ERR_INVALID_CHARS is not supported for UTF-8 under XP
// and for UTF-7 under any Windows version, so we always use our own
// conversions in this case.
if ( m_CodePage == CP_UTF8 )
{
return wxMBConvUTF8().MB2WC(buf, psz, n);
}
// But MB_ERR_INVALID_CHARS is not supported for UTF-7, so we always
// use our own conversions in this case.
if ( m_CodePage == CP_UTF7 )
{
return wxMBConvUTF7().MB2WC(buf, psz, n);

View file

@ -2148,11 +2148,12 @@ int wxDataViewMainWindow::GetDefaultRowHeight() const
#ifdef __WXMSW__
// We would like to use the same line height that Explorer uses. This is
// different from standard ListView control since Vista.
if ( wxGetWinVersion() >= wxWinVersion_Vista )
return wxMax(SMALL_ICON_HEIGHT, GetCharHeight()) + FromDIP(6);
else
#endif // __WXMSW__
return wxMax(SMALL_ICON_HEIGHT, GetCharHeight()) + FromDIP(1);
const int EXTRA_MARGIN = 6;
#else // !__WXMSW__
const int EXTRA_MARGIN = 1;
#endif // __WXMSW__/!__WXMSW__
return wxMax(SMALL_ICON_HEIGHT, GetCharHeight()) + FromDIP(EXTRA_MARGIN);
}

View file

@ -92,7 +92,7 @@ public:
#ifdef HAVE_MSW_THEME
// When using themes MSW tooltips use larger bluish version of the
// normal font.
if ( UseTooltipTheme() )
if ( wxUxThemeIsActive() )
{
titleFont.MakeLarger();
@ -136,7 +136,7 @@ public:
wxSizer* sizerText = wrapper.CreateSizer(message, -1 /* No wrapping */);
#ifdef HAVE_MSW_THEME
if ( icon.IsOk() && UseTooltipTheme() )
if ( icon.IsOk() && wxUxThemeIsActive() )
{
// Themed tooltips under MSW align the text with the title, not
// with the icon, so use a helper horizontal sizer in this case.
@ -171,7 +171,7 @@ public:
{
// Determine the best colour(s) to use on our own.
#ifdef HAVE_MSW_THEME
if ( UseTooltipTheme() )
if ( wxUxThemeIsActive() )
{
wxUxThemeHandle hTheme(GetParent(), L"TOOLTIP");
@ -273,24 +273,12 @@ protected:
}
private:
#ifdef HAVE_MSW_THEME
// Returns non-null theme only if we're using Win7-style tooltips.
static bool UseTooltipTheme()
{
// Even themed applications under XP still use "classic" tooltips.
if ( wxGetWinVersion() <= wxWinVersion_XP )
return false;
else
return wxUxThemeIsActive();
}
#endif // HAVE_MSW_THEME
// For now we just hard code the tip height, would be nice to do something
// smarter in the future.
static int GetTipHeight()
{
#ifdef HAVE_MSW_THEME
if ( UseTooltipTheme() )
if ( wxUxThemeIsActive() )
return 20;
#endif // HAVE_MSW_THEME

View file

@ -325,7 +325,7 @@ namespace
Helper class to manipulate console from a GUI app.
Notice that console output is available in the GUI app only if:
- AttachConsole() returns TRUE (which means it never works under pre-XP)
- AttachConsole() returns TRUE
- we have a valid STD_ERROR_HANDLE
- command history hasn't been changed since our startup

View file

@ -95,29 +95,6 @@ SHSTOCKICONID MSWGetStockIconIdForArtProviderId(const wxArtID& art_id)
};
// try to load SHGetStockIconInfo dynamically, so this code runs
// even on pre-Vista Windows versions
HRESULT
MSW_SHGetStockIconInfo(SHSTOCKICONID siid,
UINT uFlags,
SHSTOCKICONINFO *psii)
{
typedef HRESULT (WINAPI *PSHGETSTOCKICONINFO)(SHSTOCKICONID, UINT, SHSTOCKICONINFO *);
static PSHGETSTOCKICONINFO pSHGetStockIconInfo = (PSHGETSTOCKICONINFO)-1;
if ( pSHGetStockIconInfo == (PSHGETSTOCKICONINFO)-1 )
{
wxDynamicLibrary shell32(wxT("shell32.dll"));
pSHGetStockIconInfo = (PSHGETSTOCKICONINFO)shell32.RawGetSymbol( wxT("SHGetStockIconInfo") );
}
if ( !pSHGetStockIconInfo )
return E_FAIL;
return pSHGetStockIconInfo(siid, uFlags, psii);
}
#endif // #ifdef wxHAS_SHGetStockIconInfo
// Wrapper for SHDefExtractIcon().
@ -200,7 +177,6 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id,
: wxArtProvider::GetNativeSizeHint(client);
#ifdef wxHAS_SHGetStockIconInfo
// first try to use SHGetStockIconInfo, available only on Vista and higher
SHSTOCKICONID stockIconId = MSWGetStockIconIdForArtProviderId( id );
if ( stockIconId != SIID_INVALID )
{
@ -208,7 +184,7 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id,
UINT uFlags = SHGSI_ICONLOCATION | SHGSI_SYSICONINDEX;
HRESULT res = MSW_SHGetStockIconInfo(stockIconId, uFlags, &sii);
HRESULT res = ::SHGetStockIconInfo(stockIconId, uFlags, &sii);
if ( res == S_OK )
{
bitmap = MSWGetBitmapFromIconLocation(sii.szPath, sii.iIcon,

View file

@ -461,13 +461,9 @@ bool wxButton::DoGetAuthNeeded() const
void wxButton::DoSetAuthNeeded(bool show)
{
// show/hide UAC symbol on Windows Vista and later
if ( wxGetWinVersion() >= wxWinVersion_6 )
{
m_authNeeded = show;
::SendMessage(GetHwnd(), BCM_SETSHIELD, 0, show);
InvalidateBestSize();
}
m_authNeeded = show;
::SendMessage(GetHwnd(), BCM_SETSHIELD, 0, show);
InvalidateBestSize();
}
#endif // wxUSE_BUTTON

View file

@ -178,14 +178,6 @@ wxCalendarCtrl::HitTest(const wxPoint& pos,
{
WinStruct<MCHITTESTINFO> hti;
// Vista and later SDKs add a few extra fields to MCHITTESTINFO which are
// not supported by the previous versions, as we don't use them anyhow we
// should pretend that we always use the old struct format to make the call
// below work on pre-Vista systems (see #11057)
#ifdef MCHITTESTINFO_V1_SIZE
hti.cbSize = MCHITTESTINFO_V1_SIZE;
#endif
hti.pt.x = pos.x;
hti.pt.y = pos.y;
switch ( MonthCal_HitTest(GetHwnd(), &hti) )

View file

@ -105,8 +105,8 @@ bool wxComboCtrl::Create(wxWindow *parent,
name) )
return false;
if ( wxUxThemeIsActive() && ::wxGetWinVersion() >= wxWinVersion_Vista )
m_iFlags |= wxCC_BUTTON_STAYS_DOWN |wxCC_BUTTON_COVERS_BORDER;
if ( wxUxThemeIsActive() )
m_iFlags |= wxCC_BUTTON_STAYS_DOWN |wxCC_BUTTON_COVERS_BORDER;
if ( style & wxCC_STD_BUTTON )
m_iFlags |= wxCC_POPUP_ON_MOUSE_UP;
@ -346,8 +346,6 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
#if wxUSE_UXTHEME
if ( hTheme )
{
const bool useVistaComboBox = ::wxGetWinVersion() >= wxWinVersion_Vista;
RECT rFull;
wxCopyRectToRECT(borderRect, rFull);
@ -368,10 +366,8 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
{
butState = CBXS_DISABLED;
}
// Vista will display the drop-button as depressed always
// when the popup window is visilbe
else if ( (m_btnState & wxCONTROL_PRESSED) ||
(useVistaComboBox && !IsPopupWindowState(Hidden)) )
!IsPopupWindowState(Hidden) )
{
butState = CBXS_PRESSED;
}
@ -384,40 +380,37 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
butState = CBXS_NORMAL;
}
int comboBoxPart = 0; // For XP, use the 'default' part
int comboBoxPart wxDUMMY_INITIALIZE(0);
RECT* rUseForBg = &rBorder;
bool drawFullButton = false;
int bgState = butState;
const bool isFocused = (FindFocus() == GetMainWindowOfCompositeControl()) ? true : false;
if ( useVistaComboBox )
// Draw the entire control as a single button?
if ( !isNonStdButton )
{
// Draw the entire control as a single button?
if ( !isNonStdButton )
{
if ( HasFlag(wxCB_READONLY) )
drawFullButton = true;
}
if ( HasFlag(wxCB_READONLY) )
drawFullButton = true;
}
if ( drawFullButton )
{
comboBoxPart = CP_READONLY;
rUseForBg = &rFull;
if ( drawFullButton )
{
comboBoxPart = CP_READONLY;
rUseForBg = &rFull;
// It should be safe enough to update this flag here.
m_iFlags |= wxCC_FULL_BUTTON;
}
// It should be safe enough to update this flag here.
m_iFlags |= wxCC_FULL_BUTTON;
}
else
{
comboBoxPart = CP_BORDER;
m_iFlags &= ~wxCC_FULL_BUTTON;
if ( isFocused )
bgState = CBB_FOCUSED;
else
{
comboBoxPart = CP_BORDER;
m_iFlags &= ~wxCC_FULL_BUTTON;
if ( isFocused )
bgState = CBB_FOCUSED;
else
bgState = CBB_NORMAL;
}
bgState = CBB_NORMAL;
}
//
@ -455,27 +448,23 @@ void wxComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
int butPart = CP_DROPDOWNBUTTON;
if ( useVistaComboBox )
if ( drawFullButton )
{
if ( drawFullButton )
{
// We need to alter the button style slightly before
// drawing the actual button (but it was good above
// when background etc was done).
if ( butState == CBXS_HOT || butState == CBXS_PRESSED )
butState = CBXS_NORMAL;
}
if ( m_btnSide == wxRIGHT )
butPart = CP_DROPDOWNBUTTONRIGHT;
else
butPart = CP_DROPDOWNBUTTONLEFT;
// We need to alter the button style slightly before
// drawing the actual button (but it was good above
// when background etc was done).
if ( butState == CBXS_HOT || butState == CBXS_PRESSED )
butState = CBXS_NORMAL;
}
if ( m_btnSide == wxRIGHT )
butPart = CP_DROPDOWNBUTTONRIGHT;
else
butPart = CP_DROPDOWNBUTTONLEFT;
::DrawThemeBackground( hTheme, hDc, butPart, butState, &rButton, nullptr );
}
else if ( useVistaComboBox &&
(m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE) )
else if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE )
{
// We'll do this, because DrawThemeParentBackground
// doesn't seem to be reliable on Vista.

View file

@ -760,24 +760,6 @@ void wxComboBox::DoSetToolTip(wxToolTip *tip)
#endif // wxUSE_TOOLTIPS
#if wxUSE_UXTHEME
bool wxComboBox::SetHint(const wxString& hintOrig)
{
wxString hint(hintOrig);
if ( wxUxThemeIsActive() )
{
// under XP (but not Vista) there is a bug in cue banners
// implementation for combobox edit control: the first character is
// partially chopped off, so prepend a space to make it fully visible
hint.insert(0, " ");
}
return wxTextEntry::SetHint(hint);
}
#endif // wxUSE_UXTHEME
wxSize wxComboBox::DoGetSizeFromTextSize(int xlen, int ylen) const
{
wxSize tsize( wxChoice::DoGetSizeFromTextSize(xlen, ylen) );

View file

@ -101,17 +101,8 @@ void wxDatePickerCtrl::SetValue(const wxDateTime& dt)
{
if ( dt.IsValid() )
{
// Don't try setting the date if it's out of range: calendar control
// under XP (and presumably all the other pre-Vista Windows versions)
// doesn't return false from DateTime_SetSystemtime() in this case but
// doesn't actually change the date, so we can't update our m_date
// unconditionally and would need to check whether it was changed
// before doing it. It looks simpler to just check whether it's in
// range here instead.
//
// If we ever drop support for XP we could rely on the return value of
// DateTime_SetSystemtime() but this probably won't happen in near
// future.
// Don't try setting the date if it's out of range as we can't rely on
// DateTime_SetSystemtime() always returning FALSE for it.
wxDateTime dtStart, dtEnd;
GetRange(&dtStart, &dtEnd);
if ( (dtStart.IsValid() && dt < dtStart) ||

View file

@ -169,66 +169,63 @@ wxSize wxDateTimePickerCtrl::DoGetBestSize() const
{
wxSize size;
// Use DTM_GETIDEALSIZE to ask the control itself to compute its ideal size.
SIZE idealSize = { 0, 0 };
if ( wxGetWinVersion() >= wxWinVersion_Vista )
// Use DTM_GETIDEALSIZE to ask the control itself to compute its ideal
// size, but we can't use it with DTS_SHOWNONE because handling of
// this flag is completely broken (up to at least Window 10 20H2): it's
// not just ignored, but we get completely wrong results when this flag
// is on, e.g. the returned width is less than the width without it or
// much greater than the real value after a DPI change (and growing
// with every new change, even when repeatedly switching between the
// same DPI values, e.g. dragging a window between 2 monitors with
// different scaling). Moreover, note that even without DTS_SHOWNONE,
// DTM_GETIDEALSIZE still returns wrong results for the height after a
// DPI change, so we never use the vertical component of the value
// returned by it.
//
// Unfortunately, resetting this style doesn't work either, so we have
// to create a whole new window just for this, which is pretty wasteful
// but seems unavoidable.
HWND hwnd;
if ( MSWAllowsNone() )
{
// We can't use DTM_GETIDEALSIZE with DTS_SHOWNONE because handling of
// this flag is completely broken (up to at least Window 10 20H2): it's
// not just ignored, but we get completely wrong results when this flag
// is on, e.g. the returned width is less than the width without it or
// much greater than the real value after a DPI change (and growing
// with every new change, even when repeatedly switching between the
// same DPI values, e.g. dragging a window between 2 monitors with
// different scaling). Moreover, note that even without DTS_SHOWNONE,
// DTM_GETIDEALSIZE still returns wrong results for the height after a
// DPI change, so we never use the vertical component of the value
// returned by it.
//
// Unfortunately, resetting this style doesn't work either, so we have
// to create a whole new window just for this, which is pretty wasteful
// but seems unavoidable.
HWND hwnd;
if ( MSWAllowsNone() )
{
hwnd = ::CreateWindow
(
DATETIMEPICK_CLASS,
wxT(""),
::GetWindowLong(GetHwnd(), GWL_STYLE) & ~DTS_SHOWNONE,
0, 0, 1, 1,
GetHwndOf(m_parent),
0,
wxGetInstance(),
nullptr
);
wxCHECK_MSG( hwnd, wxSize(),
wxS("SysDateTimePick32 creation unexpected failed") );
hwnd = ::CreateWindow
(
DATETIMEPICK_CLASS,
wxT(""),
::GetWindowLong(GetHwnd(), GWL_STYLE) & ~DTS_SHOWNONE,
0, 0, 1, 1,
GetHwndOf(m_parent),
0,
wxGetInstance(),
nullptr
);
wxCHECK_MSG( hwnd, wxSize(),
wxS("SysDateTimePick32 creation unexpected failed") );
wxSetWindowFont(hwnd, GetFont());
}
else
{
hwnd = GetHwnd();
}
// Also 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, and returns FALSE for it.
if ( ::SendMessage(hwnd, DTM_GETIDEALSIZE, 0, (LPARAM)&idealSize) )
{
size.x = idealSize.cx;
size.y = GetCharHeight();
}
if ( hwnd != GetHwnd() )
{
::DestroyWindow(hwnd);
}
wxSetWindowFont(hwnd, GetFont());
}
else
{
hwnd = GetHwnd();
}
if ( !idealSize.cx ) // Compute the size ourselves.
// Also 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, and returns FALSE for it.
SIZE idealSize = { 0, 0 };
if ( ::SendMessage(hwnd, DTM_GETIDEALSIZE, 0, (LPARAM)&idealSize) )
{
size.x = idealSize.cx;
size.y = GetCharHeight();
}
if ( hwnd != GetHwnd() )
{
::DestroyWindow(hwnd);
}
if ( !size.x ) // Compute the size ourselves.
{
// Use the same native format as the underlying native control.
#if wxUSE_INTL

View file

@ -151,19 +151,7 @@ int wxDirDialog::ShowModal()
// Use IFileDialog under new enough Windows, it's more user-friendly.
int rc;
#if wxUSE_IFILEOPENDIALOG
// While the new dialog is available under Vista, it may return a wrong
// path there (see http://support.microsoft.com/kb/969885/en-us), so we
// don't use it there by default. We could improve the version test to
// allow its use if the comdlg32.dll version is greater than 6.0.6002.22125
// as this means that the hotfix correcting this bug is installed.
if ( wxGetWinVersion() > wxWinVersion_Vista )
{
rc = ShowIFileOpenDialog(hWndParent);
}
else
{
rc = wxID_NONE;
}
rc = ShowIFileOpenDialog(hWndParent);
if ( rc == wxID_NONE )
#endif // wxUSE_IFILEOPENDIALOG
@ -234,7 +222,7 @@ int wxDirDialog::ShowSHBrowseForFolder(WXHWND owner)
return m_path.empty() ? wxID_CANCEL : wxID_OK;
}
// Function for obtaining folder name on Vista and newer.
// Function for obtaining folder name using IFileDialog.
//
// Returns wxID_OK on success, wxID_CANCEL if cancelled by user or wxID_NONE if
// an error occurred and we should fall back onto the old dialog.
@ -356,36 +344,6 @@ HRESULT InitShellItemFromPath(wxCOMPtr<IShellItem>& item, const wxString& path)
{
HRESULT hr;
// We need to link SHCreateItemFromParsingName() dynamically as it's
// not available on pre-Vista systems.
typedef HRESULT
(WINAPI *SHCreateItemFromParsingName_t)(PCWSTR,
IBindCtx*,
REFIID,
void**);
static SHCreateItemFromParsingName_t
s_pfnSHCreateItemFromParsingName = (SHCreateItemFromParsingName_t)-1;
if ( s_pfnSHCreateItemFromParsingName == (SHCreateItemFromParsingName_t)-1 )
{
wxDynamicLibrary dllShell32;
if ( dllShell32.Load(wxS("shell32.dll"), wxDL_VERBATIM | wxDL_QUIET) )
{
wxDL_INIT_FUNC(s_pfn, SHCreateItemFromParsingName, dllShell32);
}
if ( !s_pfnSHCreateItemFromParsingName )
{
wxLogLastError(wxS("SHCreateItemFromParsingName() not found"));
}
}
if ( !s_pfnSHCreateItemFromParsingName )
{
// There is nothing we can do and the error was already reported.
return E_FAIL;
}
// SHCreateItemFromParsingName() doesn't support slashes, so if the path
// uses them, replace them with the backslashes.
wxString pathBS;
@ -402,7 +360,7 @@ HRESULT InitShellItemFromPath(wxCOMPtr<IShellItem>& item, const wxString& path)
pathWithoutSlashes = &path;
}
hr = s_pfnSHCreateItemFromParsingName
hr = ::SHCreateItemFromParsingName
(
pathWithoutSlashes->wc_str(),
nullptr,

View file

@ -236,47 +236,11 @@ wxDynamicLibraryDetailsArray wxDynamicLibrary::ListLoaded()
// Getting the module from an address inside it
// ----------------------------------------------------------------------------
namespace
{
// Tries to dynamically load GetModuleHandleEx() from kernel32.dll and call it
// to get the module handle from the given address. Returns nullptr if it fails to
// either resolve the function (which can only happen on pre-Vista systems
// normally) or if the function itself failed.
HMODULE CallGetModuleHandleEx(const void* addr)
{
typedef BOOL (WINAPI *GetModuleHandleEx_t)(DWORD, LPCTSTR, HMODULE *);
static const GetModuleHandleEx_t INVALID_FUNC_PTR = (GetModuleHandleEx_t)-1;
static GetModuleHandleEx_t s_pfnGetModuleHandleEx = INVALID_FUNC_PTR;
if ( s_pfnGetModuleHandleEx == INVALID_FUNC_PTR )
{
wxDynamicLibrary dll(wxT("kernel32.dll"), wxDL_VERBATIM);
wxDL_INIT_FUNC_AW(s_pfn, GetModuleHandleEx, dll);
// dll object can be destroyed, kernel32.dll won't be unloaded anyhow
}
if ( !s_pfnGetModuleHandleEx )
return nullptr;
// flags are GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
// GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
HMODULE hmod;
if ( !s_pfnGetModuleHandleEx(6, (LPCTSTR)addr, &hmod) )
return nullptr;
return hmod;
}
} // anonymous namespace
/* static */
void* wxDynamicLibrary::GetModuleFromAddress(const void* addr, wxString* path)
{
HMODULE hmod = CallGetModuleHandleEx(addr);
if ( !hmod )
HMODULE hmod;
if ( !::GetModuleHandleEx(0, (LPCTSTR)addr, &hmod) || !hmod )
{
wxLogLastError(wxT("GetModuleHandleEx"));
return nullptr;
@ -312,9 +276,11 @@ WXHMODULE wxDynamicLibrary::MSWGetModuleHandle(const wxString& name, void *addr)
// because the former works correctly for comctl32.dll while the latter
// returns nullptr when comctl32.dll version 6 is used under XP (note that
// GetModuleHandleEx() is only available under XP and later, coincidence?)
HMODULE hmod = CallGetModuleHandleEx(addr);
HMODULE hmod;
if ( !addr || !::GetModuleHandleEx(0, (LPCTSTR)addr, &hmod) || !hmod )
hmod = ::GetModuleHandle(name.t_str());
return hmod ? hmod : ::GetModuleHandle(name.t_str());
return hmod;
}
#endif // wxUSE_DYNLIB_CLASS

View file

@ -150,9 +150,7 @@ void wxHyperlinkCtrl::SetLabel(const wxString &label)
wxSize wxHyperlinkCtrl::DoGetBestClientSize() const
{
// LM_GETIDEALSIZE only exists under Vista so use the generic version even
// when using the native control under XP
if ( !HasNativeHyperlinkCtrl() || (wxGetWinVersion() < wxWinVersion_6) )
if ( !HasNativeHyperlinkCtrl() )
return wxGenericHyperlinkCtrl::DoGetBestClientSize();
SIZE idealSize;

View file

@ -2343,17 +2343,6 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
}
break;
case HDN_GETDISPINFOW:
// letting Windows XP handle this message results in mysterious
// crashes in comctl32.dll seemingly because of bad message
// parameters
//
// I have no idea what is the real cause of the bug (which is,
// just to make things interesting, impossible to reproduce
// reliably) but ignoring all these messages does fix it and
// doesn't seem to have any negative consequences
return true;
case NM_CUSTOMDRAW:
if ( m_headerCustomDraw )
{

View file

@ -284,7 +284,6 @@ public:
enum MenuLayoutType
{
FullTheme, // full menu themes (Vista or new)
PseudoTheme, // pseudo menu themes (on XP)
Classic
};
@ -293,13 +292,7 @@ public:
MenuLayoutType menu = Classic;
#if wxUSE_UXTHEME
if ( wxUxThemeIsActive() )
{
static wxWinVersion ver = wxGetWinVersion();
if ( ver >= wxWinVersion_Vista )
menu = FullTheme;
else if ( ver == wxWinVersion_XP )
menu = PseudoTheme;
}
menu = FullTheme;
#endif // wxUSE_UXTHEME
return menu;
}
@ -678,7 +671,7 @@ wxBitmap wxMenuItem::GetBitmap(bool bChecked) const
{
wxBitmap bmp = GetBitmapFromBundle(bChecked ? m_bitmap : m_bmpUnchecked);
#if wxUSE_IMAGE
if ( bmp.IsOk() && wxGetWinVersion() >= wxWinVersion_Vista)
if ( bmp.IsOk() )
{
// we must use PARGB DIB for the menu bitmaps so ensure that we do
if ( !bmp.HasAlpha() )
@ -1296,33 +1289,9 @@ void wxMenuItem::GetColourToUse(wxODStatus stat, wxColour& colText, wxColour& co
bool wxMenuItem::MSWMustUseOwnerDrawn()
{
// we have to use owner drawn item if it has custom colours or font
bool mustUseOwnerDrawn = GetTextColour().IsOk() ||
GetBackgroundColour().IsOk() ||
GetFont().IsOk();
// Windows XP or earlier don't display menu bitmaps bigger than
// standard size correctly (they're truncated) nor can
// checked bitmaps use HBMMENU_CALLBACK, so we must use
// owner-drawn items to show them correctly there. OTOH Win7
// doesn't seem to have any problems with even very large bitmaps
// so don't use owner-drawn items unnecessarily there (Vista wasn't
// actually tested but I assume it works as 7 rather than as XP).
static const wxWinVersion winver = wxGetWinVersion();
if ( !mustUseOwnerDrawn && winver < wxWinVersion_Vista )
{
const wxBitmap& bmpUnchecked = GetBitmap(false),
bmpChecked = GetBitmap(true);
const wxWindow* win = m_parentMenu ? m_parentMenu->GetWindow() : nullptr;
if ( (bmpUnchecked.IsOk() && IsGreaterThanStdSize(bmpUnchecked, win)) ||
(bmpChecked.IsOk() && IsGreaterThanStdSize(bmpChecked, win)) ||
(bmpChecked.IsOk() && IsCheckable()) )
{
mustUseOwnerDrawn = true;
}
}
return mustUseOwnerDrawn;
return GetTextColour().IsOk() ||
GetBackgroundColour().IsOk() ||
GetFont().IsOk();
}
#endif // wxUSE_OWNER_DRAWN
@ -1330,40 +1299,18 @@ bool wxMenuItem::MSWMustUseOwnerDrawn()
// returns the HBITMAP to use in MENUITEMINFO
HBITMAP wxMenuItem::GetHBitmapForMenu(BitmapKind kind) const
{
// Under versions of Windows older than Vista we can't pass HBITMAP
// directly as hbmpItem for 2 reasons:
// 1. We can't draw it with transparency then (this is not
// very important now but would be with themed menu bg)
// 2. Worse, Windows inverts the bitmap for the selected
// item and this looks downright ugly
//
// So we prefer to instead draw it ourselves in MSWOnDrawItem() by using
// HBMMENU_CALLBACK for normal menu items when inserting it. And use
// nullptr for checkable menu items as hbmpChecked/hBmpUnchecked does not
// support HBMMENU_CALLBACK.
//
// However under Vista using HBMMENU_CALLBACK causes the entire menu to be
// drawn using the classic theme instead of the current one and it does
// handle transparency just fine so do use the real bitmap there
#if wxUSE_IMAGE
if ( wxGetWinVersion() >= wxWinVersion_Vista )
// We need to store the returned bitmap, so that its HBITMAP remains
// valid for as long as it's used.
bool checked = (kind != Unchecked);
wxBitmap& bmp = const_cast<wxBitmap&>(checked ? m_bmpCheckedCurrent
: m_bmpUncheckedCurrent);
bmp = GetBitmap(checked);
if ( bmp.IsOk() )
{
// We need to store the returned bitmap, so that its HBITMAP remains
// valid for as long as it's used.
bool checked = (kind != Unchecked);
wxBitmap& bmp = const_cast<wxBitmap&>(checked ? m_bmpCheckedCurrent
: m_bmpUncheckedCurrent);
bmp = GetBitmap(checked);
if ( bmp.IsOk() )
{
return GetHbitmapOf(bmp);
}
//else: bitmap is not set
return nullptr;
return GetHbitmapOf(bmp);
}
#endif // wxUSE_IMAGE
return (kind == Normal) ? HBMMENU_CALLBACK : nullptr;
//else: bitmap is not set
return nullptr;
}
int wxMenuItem::MSGetMenuItemPos() const

View file

@ -277,12 +277,8 @@ wxString wxAssocQueryString(ASSOCSTR assoc,
if ( hr != S_OK )
{
// The only really expected error here is that no association is
// defined, anything else is not expected. The confusing thing is that
// different errors are returned for this expected error under
// different Windows versions: XP returns ERROR_FILE_NOT_FOUND while 7
// returns ERROR_NO_ASSOCIATION. Just check for both to be sure.
if ( hr != HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) &&
hr != HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) )
// defined, anything else is not expected.
if ( hr != HRESULT_FROM_WIN32(ERROR_NO_ASSOCIATION) )
{
wxLogApiError("AssocQueryString", hr);
}

View file

@ -743,22 +743,9 @@ bool wxRegKey::DeleteSelf()
Close();
// deleting a key which doesn't exist is not considered an error
#if wxUSE_DYNLIB_CLASS
wxDynamicLibrary dllAdvapi32(wxT("advapi32"));
// Minimum supported OS for RegDeleteKeyEx: Vista, XP Pro x64, Win Server 2008, Win Server 2003 SP1
typedef LONG (WINAPI *RegDeleteKeyEx_t)(HKEY, LPCTSTR, REGSAM, DWORD);
RegDeleteKeyEx_t wxDL_INIT_FUNC_AW(pfn, RegDeleteKeyEx, dllAdvapi32);
if (pfnRegDeleteKeyEx)
{
m_dwLastError = (*pfnRegDeleteKeyEx)((HKEY) m_hRootKey, m_strKey.t_str(),
GetMSWViewFlags(m_viewMode),
wxRESERVED_PARAM);
}
else
#endif // wxUSE_DYNLIB_CLASS
{
m_dwLastError = RegDeleteKey((HKEY) m_hRootKey, m_strKey.t_str());
}
m_dwLastError = ::RegDeleteKeyEx((HKEY) m_hRootKey, m_strKey.t_str(),
GetMSWViewFlags(m_viewMode),
wxRESERVED_PARAM);
if ( m_dwLastError != ERROR_SUCCESS &&
m_dwLastError != ERROR_FILE_NOT_FOUND ) {

View file

@ -38,30 +38,6 @@
#include "wx/msw/wrapcctl.h"
#include "wx/dynlib.h"
// These Vista+ only types used by DrawThemeTextEx may not be available in older SDK headers
typedef int(__stdcall *WXDTT_CALLBACK_PROC)(HDC hdc, const wchar_t * pszText,
int cchText, RECT * prc, unsigned int dwFlags, WXLPARAM lParam);
typedef struct _WXDTTOPTS
{
DWORD dwSize;
DWORD dwFlags;
COLORREF crText;
COLORREF crBorder;
COLORREF crShadow;
int iTextShadowType;
POINT ptShadowOffset;
int iBorderSize;
int iFontPropId;
int iColorPropId;
int iStateId;
BOOL fApplyOverlay;
int iGlowSize;
WXDTT_CALLBACK_PROC pfnDrawTextCallback;
WXLPARAM lParam;
} WXDTTOPTS, *WXPDTTOPTS;
// ----------------------------------------------------------------------------
// methods common to wxRendererMSW and wxRendererXP
// ----------------------------------------------------------------------------
@ -1048,31 +1024,11 @@ void wxRendererXP::DrawItemText(wxWindow* win,
const int itemState = GetListItemState(flags);
typedef HRESULT(__stdcall *DrawThemeTextEx_t)(HTHEME, HDC, int, int, const wchar_t *, int, DWORD, RECT *, const WXDTTOPTS *);
typedef HRESULT(__stdcall *GetThemeTextExtent_t)(HTHEME, HDC, int, int, const wchar_t *, int, DWORD, RECT *, RECT *);
static DrawThemeTextEx_t s_DrawThemeTextEx = nullptr;
static GetThemeTextExtent_t s_GetThemeTextExtent = nullptr;
static bool s_initDone = false;
if ( !s_initDone )
{
if (wxGetWinVersion() >= wxWinVersion_Vista)
{
wxLoadedDLL dllUxTheme(wxS("uxtheme.dll"));
wxDL_INIT_FUNC(s_, DrawThemeTextEx, dllUxTheme);
wxDL_INIT_FUNC(s_, GetThemeTextExtent, dllUxTheme);
}
s_initDone = true;
}
if ( s_DrawThemeTextEx && // Not available under XP
::IsThemePartDefined(hTheme, LVP_LISTITEM, 0) )
if ( ::IsThemePartDefined(hTheme, LVP_LISTITEM, 0) )
{
RECT rc = ConvertToRECT(dc, rect);
WXDTTOPTS textOpts;
DTTOPTS textOpts;
textOpts.dwSize = sizeof(textOpts);
textOpts.dwFlags = DTT_STATEID;
textOpts.iStateId = itemState;
@ -1119,97 +1075,94 @@ void wxRendererXP::DrawItemText(wxWindow* win,
*/
bool useTopDrawing = false;
if ( s_GetThemeTextExtent != nullptr )
/*
Get the actual text extent using GetThemeTextExtent() and adjust
drawing rect if needed.
Note that DrawThemeTextEx() in combination with DT_CALCRECT
and DTT_CALCRECT can also be used to get the text extent.
This seems to always result in the exact same extent (checked
with an assert) as using GetThemeTextExtent(), despite having
an additional DTTOPTS argument for various effects.
Some effects have been tried (DTT_BORDERSIZE, DTT_SHADOWTYPE
and DTT_SHADOWOFFSET) and while rendered correctly with effects
the returned extent remains the same as without effects.
Official docs don't seem to prefer one method over the other
though a possibly outdated note for DrawThemeText() recommends
using GetThemeTextExtent(). Because Wine as of writing doesn't
support DT_CALCRECT with DrawThemeTextEx() while it does support
GetThemeTextExtent(), opt to use the latter.
*/
/*
It's important for the dwTextFlags parameter passed to
GetThemeTextExtent() not to have some DT_* flags because they
influence the extent size in unwanted ways: Using
DT_SINGLELINE combined with either DT_VCENTER or DT_BOTTOM
results in a height that can't be used (either halved or 0),
and having DT_END_ELLIPSIS ends up always ellipsizing.
Passing a non-null rect solves these problems but is not
really a good option as it doesn't make the rectangle extent
a tight fit and calculations would have to be done with large
numbers needlessly (provided the passed rect is set to
something like {0, 0, LONG_MAX, LONG_MAX} ).
*/
RECT rcExtent;
HRESULT hr = ::GetThemeTextExtent(hTheme, dc.GetHDC(),
LVP_LISTITEM, itemState, text.wchar_str(), -1,
defTextFlags, nullptr, &rcExtent);
if ( SUCCEEDED(hr) )
{
/*
Get the actual text extent using GetThemeTextExtent() and adjust
drawing rect if needed.
Note that DrawThemeTextEx() in combination with DT_CALCRECT
and DTT_CALCRECT can also be used to get the text extent.
This seems to always result in the exact same extent (checked
with an assert) as using GetThemeTextExtent(), despite having
an additional WXDTTOPTS argument for various effects.
Some effects have been tried (DTT_BORDERSIZE, DTT_SHADOWTYPE
and DTT_SHADOWOFFSET) and while rendered correctly with effects
the returned extent remains the same as without effects.
Official docs don't seem to prefer one method over the other
though a possibly outdated note for DrawThemeText() recommends
using GetThemeTextExtent(). Because Wine as of writing doesn't
support DT_CALCRECT with DrawThemeTextEx() while it does support
GetThemeTextExtent(), opt to use the latter.
Compensate for rare cases where the horizontal extents differ
slightly. Don't use the width of the passed rect here to deal
with horizontal alignment as it results in the text always
fitting and ellipsization then can't occur. Instead check for
width differences by comparing with the extent as calculated
by wxDC.
*/
const int textWidthDc = dc.GetMultiLineTextExtent(text).x;
const int widthDiff = textWidthDc - rcExtent.right;
if ( widthDiff )
{
if ( align & wxALIGN_CENTRE_HORIZONTAL )
{
const int widthOffset = widthDiff / 2;
rc.left += widthOffset;
rc.right -= widthOffset;
}
else if ( align & wxALIGN_RIGHT )
rc.left += widthDiff;
else // left aligned
rc.right -= widthDiff;
}
/*
It's important for the dwTextFlags parameter passed to
GetThemeTextExtent() not to have some DT_* flags because they
influence the extent size in unwanted ways: Using
DT_SINGLELINE combined with either DT_VCENTER or DT_BOTTOM
results in a height that can't be used (either halved or 0),
and having DT_END_ELLIPSIS ends up always ellipsizing.
Passing a non-null rect solves these problems but is not
really a good option as it doesn't make the rectangle extent
a tight fit and calculations would have to be done with large
numbers needlessly (provided the passed rect is set to
something like {0, 0, LONG_MAX, LONG_MAX} ).
For height compare with the height of the passed rect and use
the difference for handling vertical alignment. This has
consequences for particularly multi-line text: it will now
always try to fit vertically while a rect received from wxDVC
may have its extent based on calculations for a single line
only and therefore couldn't show more than one line. This is
consistent with other major platforms where no clipping to
the rect takes places either, including non-themed MSW.
*/
RECT rcExtent;
HRESULT hr = s_GetThemeTextExtent(hTheme, dc.GetHDC(),
LVP_LISTITEM, itemState, text.wchar_str(), -1,
defTextFlags, nullptr, &rcExtent);
if ( SUCCEEDED(hr) )
if ( text.Contains(wxS('\n')) )
{
/*
Compensate for rare cases where the horizontal extents differ
slightly. Don't use the width of the passed rect here to deal
with horizontal alignment as it results in the text always
fitting and ellipsization then can't occur. Instead check for
width differences by comparing with the extent as calculated
by wxDC.
*/
const int textWidthDc = dc.GetMultiLineTextExtent(text).x;
const int widthDiff = textWidthDc - rcExtent.right;
if ( widthDiff )
{
if ( align & wxALIGN_CENTRE_HORIZONTAL )
{
const int widthOffset = widthDiff / 2;
rc.left += widthOffset;
rc.right -= widthOffset;
}
else if ( align & wxALIGN_RIGHT )
rc.left += widthDiff;
else // left aligned
rc.right -= widthDiff;
}
useTopDrawing = true;
/*
For height compare with the height of the passed rect and use
the difference for handling vertical alignment. This has
consequences for particularly multi-line text: it will now
always try to fit vertically while a rect received from wxDVC
may have its extent based on calculations for a single line
only and therefore couldn't show more than one line. This is
consistent with other major platforms where no clipping to
the rect takes places either, including non-themed MSW.
*/
if ( text.Contains(wxS('\n')) )
const int heightDiff = rect.GetHeight() - rcExtent.bottom;
if ( align & wxALIGN_CENTRE_VERTICAL )
{
useTopDrawing = true;
const int heightDiff = rect.GetHeight() - rcExtent.bottom;
if ( align & wxALIGN_CENTRE_VERTICAL )
{
const int heightOffset = heightDiff / 2;
rc.top += heightOffset;
rc.bottom -= heightOffset;
}
else if ( align & wxALIGN_BOTTOM )
rc.top += heightDiff;
else // top aligned
rc.bottom -= heightDiff;
const int heightOffset = heightDiff / 2;
rc.top += heightOffset;
rc.bottom -= heightOffset;
}
else if ( align & wxALIGN_BOTTOM )
rc.top += heightDiff;
else // top aligned
rc.bottom -= heightDiff;
}
}
@ -1248,7 +1201,7 @@ void wxRendererXP::DrawItemText(wxWindow* win,
break;
}
s_DrawThemeTextEx(hTheme, dc.GetHDC(), LVP_LISTITEM, itemState,
::DrawThemeTextEx(hTheme, dc.GetHDC(), LVP_LISTITEM, itemState,
drawText->wchar_str(), -1, textFlags, &rc, &textOpts);
}
else

View file

@ -285,24 +285,6 @@ WXLRESULT wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPar
return 0;
}
if ( nMsg == WM_UPDATEUISTATE )
{
// DefWindowProc() redraws just the static box text when it gets this
// message and it does it using the standard (blue in standard theme)
// colour and not our own label colour that we use in PaintForeground()
// resulting in the label mysteriously changing the colour when e.g.
// "Alt" is pressed anywhere in the window, see #12497.
//
// To avoid this we simply refresh the window forcing our own code
// redrawing the label in the correct colour to be called. This is
// inefficient but there doesn't seem to be anything else we can do.
//
// Notice that the problem is XP-specific and doesn't arise under later
// systems.
if ( m_hasFgCol && wxGetWinVersion() == wxWinVersion_XP )
Refresh();
}
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
@ -573,16 +555,10 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT&)
UINT drawTextFlags = DT_SINGLELINE | DT_VCENTER;
// determine the state of UI queues to draw the text correctly under XP
// and later systems
static const bool isXPorLater = wxGetWinVersion() >= wxWinVersion_XP;
if ( isXPorLater )
// determine the state of UI queues to draw the text correctly
if ( ::SendMessage(GetHwnd(), WM_QUERYUISTATE, 0, 0) & UISF_HIDEACCEL )
{
if ( ::SendMessage(GetHwnd(), WM_QUERYUISTATE, 0, 0) &
UISF_HIDEACCEL )
{
drawTextFlags |= DT_HIDEPREFIX;
}
drawTextFlags |= DT_HIDEPREFIX;
}
// now draw the text

View file

@ -19,7 +19,7 @@
void wxSystemThemedControlBase::DoEnableSystemTheme(bool enable, wxWindow* window)
{
if ( wxGetWinVersion() >= wxWinVersion_Vista && wxUxThemeIsActive() )
if ( wxUxThemeIsActive() )
{
// It's possible to call EnableSystemTheme(false) before creating the
// window, just don't do anything in this case.

View file

@ -93,19 +93,10 @@ private:
// NotifyIconData: wrapper around NOTIFYICONDATA
// ----------------------------------------------------------------------------
struct NotifyIconData : public NOTIFYICONDATA
struct NotifyIconData : public WinStruct<NOTIFYICONDATA>
{
NotifyIconData(WXHWND hwnd)
{
wxZeroMemory(*this);
// Since Vista there is a new member hBalloonIcon which will be used
// if a user specified icon is specified in ShowBalloon(). For XP
// use the old size
cbSize = wxPlatformInfo::Get().CheckOSVersion(6, 0)
? sizeof(NOTIFYICONDATA)
: NOTIFYICONDATA_V2_SIZE;
hWnd = (HWND) hwnd;
uCallbackMessage = gs_msgTaskbar;
uFlags = NIF_MESSAGE;
@ -257,8 +248,7 @@ wxTaskBarIcon::ShowBalloon(const wxString& title,
wxUnusedVar(icon); // It's only unused if not supported actually.
// User specified icon is only supported since Vista
if ( icon.IsOk() && wxPlatformInfo::Get().CheckOSVersion(6, 0) )
if ( icon.IsOk() )
{
m_balloonIcon = icon.GetIconFor(m_win);
notifyData.hBalloonIcon = GetHiconOf(m_balloonIcon);

View file

@ -902,7 +902,7 @@ void wxTextCtrl::SetWindowStyleFlag(long style)
// XP but not other ones, and we have no way to determine it so be
// conservative here) and only for plain EDIT controls (not RICH ones) and
// we have to recreate the control to make it always work
if ( IsRich() || wxGetWinVersion() < wxWinVersion_2003 )
if ( IsRich() )
{
const long alignMask = wxTE_LEFT | wxTE_CENTRE | wxTE_RIGHT;
if ( (style & alignMask) != (GetWindowStyle() & alignMask) )

View file

@ -995,7 +995,7 @@ void wxTextEntry::ForceUpper()
bool wxTextEntry::SetHint(const wxString& hint)
{
if ( wxGetWinVersion() >= wxWinVersion_Vista && wxUxThemeIsActive() )
if ( wxUxThemeIsActive() )
{
// notice that this message always works with Unicode strings
//

View file

@ -1547,32 +1547,12 @@ wxTreeItemId wxTreeCtrl::DoInsertAfter(const wxTreeItemId& parent,
tvIns.item.lParam = (LPARAM)param;
tvIns.item.mask = mask;
// apparently some Windows versions (2000 and XP are reported to do this)
// sometimes don't refresh the tree after adding the first child and so we
// need this to make the "[+]" appear
//
// don't use this hack below for the children of hidden root nor for modern
// MSW versions as it would just unnecessarily slow down the item insertion
// at best
const bool refreshFirstChild =
(wxGetWinVersion() < wxWinVersion_Vista) &&
!IsHiddenRoot(parent) &&
!TreeView_GetChild(GetHwnd(), HITEM(parent));
HTREEITEM id = TreeView_InsertItem(GetHwnd(), &tvIns);
if ( id == 0 )
{
wxLogLastError(wxT("TreeView_InsertItem"));
}
if ( refreshFirstChild )
{
TVGetItemRectParam param2;
wxTreeView_GetItemRect(GetHwnd(), HITEM(parent), param2, FALSE);
::InvalidateRect(GetHwnd(), &param2.rect, FALSE);
}
// associate the application tree item with Win32 tree item handle
param->SetItem(id);