From 1e7fcd818c7436397027600ec7849d3df17c5533 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 30 Oct 2014 08:36:14 -0400 Subject: [PATCH] Switched from using SaveDC()/RestoreDC() to just calling SetWindowOrgEx() again in the WM_CTLCOLOR** shared handler. Doesn't fix performance the way I was hoping it would, but still better. --- common_windows.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/common_windows.c b/common_windows.c index a8a2444..ca42eab 100644 --- a/common_windows.c +++ b/common_windows.c @@ -98,8 +98,7 @@ void paintControlBackground(HWND hwnd, HDC dc) { HWND parent; RECT r; - POINT p; - int saved; + POINT p, pOrig; WCHAR classname[128] = L""; // more than enough to avoid collisions parent = hwnd; @@ -123,12 +122,9 @@ void paintControlBackground(HWND hwnd, HDC dc) p.y = r.top; if (ScreenToClient(parent, &p) == 0) xpanic("error getting client origin of control in paintControlBackground()", GetLastError()); - saved = SaveDC(dc); - if (saved == 0) - xpanic("error saving DC info in paintControlBackground()", GetLastError()); - if (SetWindowOrgEx(dc, p.x, p.y, NULL) == 0) + if (SetWindowOrgEx(dc, p.x, p.y, &pOrig) == 0) xpanic("error moving window origin in paintControlBackground()", GetLastError()); SendMessageW(parent, WM_PRINTCLIENT, (WPARAM) dc, PRF_CLIENT); - if (RestoreDC(dc, saved) == 0) - xpanic("error restoring DC info in paintControlBackground()", GetLastError()); + if (SetWindowOrgEx(dc, pOrig.x, pOrig.y, NULL) == 0) + xpanic("error resetting window origin in paintControlBackground()", GetLastError()); }