mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Fixed popup menu palette issues
This commit is contained in:
parent
ac305fbbba
commit
6f643ecf7e
@ -3,6 +3,8 @@
|
|||||||
#include "CompatGdiPaintHandlers.h"
|
#include "CompatGdiPaintHandlers.h"
|
||||||
#include "CompatGdiScrollBar.h"
|
#include "CompatGdiScrollBar.h"
|
||||||
#include "CompatGdiTitleBar.h"
|
#include "CompatGdiTitleBar.h"
|
||||||
|
#include "CompatPaletteConverter.h"
|
||||||
|
#include "CompatPrimarySurface.h"
|
||||||
#include "CompatRegistry.h"
|
#include "CompatRegistry.h"
|
||||||
#include "DDrawLog.h"
|
#include "DDrawLog.h"
|
||||||
#include "Hook.h"
|
#include "Hook.h"
|
||||||
@ -159,6 +161,52 @@ namespace
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT onMenuPaint(HWND hwnd, WNDPROC origWndProc)
|
||||||
|
{
|
||||||
|
if (!hwnd || !CompatGdi::beginGdiRendering())
|
||||||
|
{
|
||||||
|
return origWndProc(hwnd, WM_PAINT, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
HDC dc = GetWindowDC(hwnd);
|
||||||
|
const bool isMenuPaintDc = true;
|
||||||
|
HDC compatDc = CompatGdiDc::getDc(dc, isMenuPaintDc);
|
||||||
|
if (compatDc)
|
||||||
|
{
|
||||||
|
if (CompatPrimarySurface::pixelFormat.dwRGBBitCount <= 8)
|
||||||
|
{
|
||||||
|
HDC converterDc = CompatPaletteConverter::lockDc();
|
||||||
|
CompatPaletteConverter::setPalette(nullptr);
|
||||||
|
|
||||||
|
origWndProc(hwnd, WM_PRINT, reinterpret_cast<WPARAM>(converterDc),
|
||||||
|
PRF_NONCLIENT | PRF_ERASEBKGND | PRF_CLIENT);
|
||||||
|
|
||||||
|
RECT rect = {};
|
||||||
|
GetWindowRect(hwnd, &rect);
|
||||||
|
CALL_ORIG_FUNC(BitBlt)(compatDc, 0, 0,
|
||||||
|
rect.right - rect.left, rect.bottom - rect.top, converterDc, 0, 0, SRCCOPY);
|
||||||
|
|
||||||
|
CompatPaletteConverter::setPalette(CompatPrimarySurface::palette);
|
||||||
|
CompatPaletteConverter::unlockDc();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
origWndProc(hwnd, WM_PRINT, reinterpret_cast<WPARAM>(compatDc),
|
||||||
|
PRF_NONCLIENT | PRF_ERASEBKGND | PRF_CLIENT);
|
||||||
|
}
|
||||||
|
ValidateRect(hwnd, nullptr);
|
||||||
|
CompatGdiDc::releaseDc(dc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
origWndProc(hwnd, WM_PAINT, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReleaseDC(hwnd, dc);
|
||||||
|
CompatGdi::endGdiRendering();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT onNcPaint(HWND hwnd, WPARAM wParam, WNDPROC origWndProc)
|
LRESULT onNcPaint(HWND hwnd, WPARAM wParam, WNDPROC origWndProc)
|
||||||
{
|
{
|
||||||
if (!hwnd || !CompatGdi::beginGdiRendering())
|
if (!hwnd || !CompatGdi::beginGdiRendering())
|
||||||
@ -189,33 +237,6 @@ namespace
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT onMenuPaint(HWND hwnd, WNDPROC origWndProc)
|
|
||||||
{
|
|
||||||
if (!hwnd || !CompatGdi::beginGdiRendering())
|
|
||||||
{
|
|
||||||
return origWndProc(hwnd, WM_PAINT, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
HDC dc = GetWindowDC(hwnd);
|
|
||||||
const bool isMenuPaintDc = true;
|
|
||||||
HDC compatDc = CompatGdiDc::getDc(dc, isMenuPaintDc);
|
|
||||||
if (compatDc)
|
|
||||||
{
|
|
||||||
origWndProc(hwnd, WM_PRINT, reinterpret_cast<WPARAM>(compatDc),
|
|
||||||
PRF_NONCLIENT | PRF_ERASEBKGND | PRF_CLIENT);
|
|
||||||
ValidateRect(hwnd, nullptr);
|
|
||||||
CompatGdiDc::releaseDc(dc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
origWndProc(hwnd, WM_PAINT, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReleaseDC(hwnd, dc);
|
|
||||||
CompatGdi::endGdiRendering();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT onPaint(HWND hwnd, WNDPROC origWndProc)
|
LRESULT onPaint(HWND hwnd, WNDPROC origWndProc)
|
||||||
{
|
{
|
||||||
if (!hwnd || !CompatGdi::beginGdiRendering())
|
if (!hwnd || !CompatGdi::beginGdiRendering())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user