diff options
| author | Pietro Gagliardi <[email protected]> | 2015-04-12 12:38:25 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2015-04-12 12:38:25 -0400 |
| commit | d0a1ae5bc9ab03132457c8c73ae723e1503952ca (patch) | |
| tree | 56c0f2dac628cc6c900472ff943581b2b68f7d7f /new/util_windows.c | |
| parent | 0ee55d2d2da1a47fb4bbe5f62144e823d07efcd1 (diff) | |
Made controls transparent to tab backgrounds on Windows. It doesn't quite work right...
Diffstat (limited to 'new/util_windows.c')
| -rw-r--r-- | new/util_windows.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/new/util_windows.c b/new/util_windows.c index e3332be..93b32d8 100644 --- a/new/util_windows.c +++ b/new/util_windows.c @@ -38,3 +38,36 @@ intmax_t uiWindowsWindowTextWidth(HWND hwnd) return size.cx; } + +// this is a helper function that takes the logic of determining window classes and puts it all in one place +// there are a number of places where we need to know what window class an arbitrary handle has +// theoretically we could use the class atom to avoid a _wcsicmp() +// however, raymond chen advises against this - http://blogs.msdn.com/b/oldnewthing/archive/2004/10/11/240744.aspx (and we're not in control of the Tab class, before you say anything) +// usage: windowClassOf(hwnd, L"class 1", L"class 2", ..., NULL) +int windowClassOf(HWND hwnd, ...) +{ +// MSDN says 256 is the maximum length of a class name; add a few characters just to be safe (because it doesn't say whether this includes the terminating null character) +#define maxClassName 260 + WCHAR classname[maxClassName + 1]; + va_list ap; + WCHAR *curname; + int i; + + if (GetClassNameW(hwnd, classname, maxClassName) == 0) + logLastError("error getting name of window class in windowClassOf()"); + va_start(ap, hwnd); + i = 0; + for (;;) { + curname = va_arg(ap, WCHAR *); + if (curname == NULL) + break; + if (_wcsicmp(classname, curname) == 0) { + va_end(ap); + return i; + } + i++; + } + // no match + va_end(ap); + return -1; +} |
