From 492845da5d3403c97c4deb85d121a131c6be87e6 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 17 Oct 2014 13:21:20 -0400 Subject: [PATCH] Adjusted background painting code on Windows for the new container structure. --- newctrl/common_windows.c | 8 ++++++-- newctrl/container_windows.c | 2 -- newctrl/winapi_windows.h | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/newctrl/common_windows.c b/newctrl/common_windows.c index 3f1a52e..b30b132 100644 --- a/newctrl/common_windows.c +++ b/newctrl/common_windows.c @@ -103,7 +103,7 @@ void paintControlBackground(HWND hwnd, HDC dc) WCHAR classname[128] = L""; // more than enough to avoid collisions parent = hwnd; - do { + for (;;) { parent = GetParent(parent); if (parent == NULL) xpanic("error getting parent container of control in paintControlBackground()", GetLastError()); @@ -117,7 +117,11 @@ void paintControlBackground(HWND hwnd, HDC dc) return; if (GetClassNameW(parent, classname, 128) == 0) xpanic("error getting name of focused window class in paintControlBackground()", GetLastError()); - } while (_wcsicmp(classname, L"button") == 0); // skip groupboxes + // skip container and groupboxes + if (_wcsicmp(classname, containerclass) != 0) // container + if (_wcsicmp(classname, L"button") != 0) // groupbox + break; + } if (GetWindowRect(hwnd, &r) == 0) xpanic("error getting control's window rect in paintControlBackground()", GetLastError()); // the above is a window rect; convert to client rect diff --git a/newctrl/container_windows.c b/newctrl/container_windows.c index 50ebc1e..bdb2e08 100644 --- a/newctrl/container_windows.c +++ b/newctrl/container_windows.c @@ -9,8 +9,6 @@ In this case, I chose to waste a window handle rather than keep things super com If this is seriously an issue in the future, I can roll it back. */ -#define containerclass L"gouicontainer" - static LRESULT CALLBACK containerWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lResult; diff --git a/newctrl/winapi_windows.h b/newctrl/winapi_windows.h index 9ee3994..c045f70 100644 --- a/newctrl/winapi_windows.h +++ b/newctrl/winapi_windows.h @@ -122,6 +122,7 @@ extern intptr_t tableSelectedItem(HWND); extern void tableSelectItem(HWND, intptr_t); // container_windows.c +#define containerclass L"gouicontainer" extern DWORD makeContainerWindowClass(char **); extern HWND newContainer(); extern void calculateBaseUnits(HWND, int *, int *, LONG *);