This is important as enabling the system theme results in changes to the native ListView control appearance that are not undone later even if the system theme is disabled. Notably, the item rectangle width is reduced by 2 pixels when system theme is enabled and it's not increased to its original value even when it's disabled later, resulting in gaps between items through which the control background shows, for example. This also makes items drawn using our own HandleItemPaint() slightly, but noticeably, larger than the items using standard appearance, which looks bad. All these problems can be avoided if we skip enabling the system theme in the first place if EnableSystemTheme(false) had been called before creating the control, so support doing it like this and document that this is the preferred way of disabling the system theme use. Closes #17404, #18296.
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: src/msw/systhemectrl.cpp
|
|
// Purpose: wxMSW implementation of wxSystemThemedControl
|
|
// Author: Tobias Taschner
|
|
// Created: 2015-09-15
|
|
// Copyright: (c) 2015 wxWidgets development team
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
#include "wx/systhemectrl.h"
|
|
|
|
#include "wx/msw/private.h"
|
|
#include "wx/msw/uxtheme.h"
|
|
|
|
#ifdef wxHAS_SYSTEM_THEMED_CONTROL
|
|
|
|
void wxSystemThemedControlBase::DoEnableSystemTheme(bool enable, wxWindow* window)
|
|
{
|
|
if ( wxGetWinVersion() >= wxWinVersion_Vista && wxUxThemeIsActive() )
|
|
{
|
|
// It's possible to call EnableSystemTheme(false) before creating the
|
|
// window, just don't do anything in this case.
|
|
if ( window->GetHandle() )
|
|
{
|
|
const wchar_t* const sysThemeId = enable ? L"EXPLORER" : NULL;
|
|
::SetWindowTheme(GetHwndOf(window), sysThemeId, NULL);
|
|
}
|
|
|
|
m_systemThemeDisabled = !enable;
|
|
}
|
|
}
|
|
|
|
#endif // wxHAS_SYSTEM_THEMED_CONTROL
|