comparison dep/animia/src/win/win32.cc @ 191:0fc126d52de4

animia: multiple stylistic choices win.class_name is now used to store bundle IDs on OS X, add some little explanations here and there for dumb stuff
author Paper <mrpapersonic@gmail.com>
date Thu, 07 Dec 2023 01:48:04 -0500
parents cdf79282d647
children bc1ae1810855
comparison
equal deleted inserted replaced
190:2d5823df870f 191:0fc126d52de4
1 /*
2 * win/win32.cc: support for Windows
3 *
4 * Surprisingly, this is the one time where Microsoft actually
5 * does it fairly OK. Everything has a pretty simple API, despite
6 * the stupid wide string stuff.
7 */
1 #include "animia/win/win32.h" 8 #include "animia/win/win32.h"
2 #include "animia.h" 9 #include "animia.h"
3 #include "animia/util/win32.h" 10 #include "animia/util/win32.h"
4 #include "animia/win.h" 11 #include "animia/win.h"
5 12
22 buffer.resize(size); 29 buffer.resize(size);
23 return buffer; 30 return buffer;
24 } 31 }
25 32
26 static std::wstring GetWindowText(HWND hwnd) { 33 static std::wstring GetWindowText(HWND hwnd) {
27 const int estimated_size = ::GetWindowTextLengthW(hwnd); 34 const auto estimated_size = ::GetWindowTextLengthW(hwnd);
35 std::wstring buffer(estimated_size + 1, L'\0');
28 36
29 std::wstring buffer(estimated_size + 1, L'\0');
30 const auto size = ::GetWindowTextW(hwnd, &buffer.front(), buffer.length()); 37 const auto size = ::GetWindowTextW(hwnd, &buffer.front(), buffer.length());
31 /* GetWindowTextLength docs: 38 /* GetWindowTextLength docs:
32 "Under certain conditions, the GetWindowTextLength function may return a value 39 "Under certain conditions, the GetWindowTextLength function may return a value
33 that is larger than the actual length of the text." */ 40 that is larger than the actual length of the text." */
34 buffer.resize(size); 41 buffer.resize(size);