diff options
Diffstat (limited to 'vcl/win/gdi/salgdi.cxx')
-rw-r--r-- | vcl/win/gdi/salgdi.cxx | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx index 43536de1fb01..6bd510b6effa 100644 --- a/vcl/win/gdi/salgdi.cxx +++ b/vcl/win/gdi/salgdi.cxx @@ -495,6 +495,7 @@ void WinSalGraphics::DeInitGraphics() SelectFont( getHDC(), mhDefFont ); mhDefFont = nullptr; } + setPalette(nullptr); mpImpl->DeInit(); } @@ -700,12 +701,32 @@ void WinSalGraphics::setHWND(HWND hWnd) HPALETTE WinSalGraphics::getDefPal() const { + assert(getHDC() || !mhDefPal); return mhDefPal; } -void WinSalGraphics::setDefPal(HPALETTE hDefPal) +void WinSalGraphics::setPalette(HPALETTE hNewPal, BOOL bForceBkgd) { - mhDefPal = hDefPal; + if (!getHDC()) + { + assert(!mhDefPal); + return; + } + + if (hNewPal) + { + HPALETTE hOldPal = SelectPalette(getHDC(), hNewPal, bForceBkgd); + if (!mhDefPal) + mhDefPal = hOldPal; + } + else + { + if (mhDefPal) + { + SelectPalette(getHDC(), mhDefPal, bForceBkgd); + mhDefPal = nullptr; + } + } } HRGN WinSalGraphics::getRegion() const |