comparison foosdk/sdk/libPPUI/win32_utility.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2 #include <functional>
3 #include <atlcomcli.h> // CComPtr
4
5 unsigned QueryScreenDPI(HWND wnd = NULL);
6 unsigned QueryScreenDPI_X(HWND wnd = NULL);
7 unsigned QueryScreenDPI_Y(HWND wnd = NULL);
8
9 SIZE QueryScreenDPIEx(HWND wnd = NULL);
10 SIZE QueryContextDPI(HDC dc);
11
12 namespace PP {
13 // Returns drag threshold, in actual pixels (DPI-corrected), for the specified window
14 SIZE queryDragThreshold(HWND wndFor);
15 SIZE queryDragThresholdForDPI(SIZE knownDPI);
16 }
17
18 void HeaderControl_SetSortIndicator(HWND header, int column, bool isUp);
19
20 HINSTANCE GetThisModuleHandle();
21
22 struct WinResourceRef_t {
23 const void * ptr;
24 size_t bytes;
25 } ;
26
27 WinResourceRef_t WinLoadResource(HMODULE hMod, const TCHAR * name, const TCHAR * type, WORD wLang = 0);
28 CComPtr<IStream> WinLoadResourceAsStream(HMODULE hMod, const TCHAR * name, const TCHAR * type, WORD wLang = 0);
29
30 UINT GetFontHeight(HFONT font);
31 UINT GetTextHeight(HDC dc);
32
33 LRESULT RelayEraseBkgnd(HWND p_from, HWND p_to, HDC p_dc);
34
35 pfc::string8 EscapeTooltipText(const char * text);
36
37 class CloseHandleScope {
38 public:
39 CloseHandleScope(HANDLE handle) throw() : m_handle(handle) {}
40 ~CloseHandleScope() throw() { CloseHandle(m_handle); }
41 HANDLE Detach() throw() { return pfc::replace_t(m_handle, INVALID_HANDLE_VALUE); }
42 HANDLE Get() const throw() { return m_handle; }
43 void Close() throw() { CloseHandle(Detach()); }
44 PFC_CLASS_NOT_COPYABLE_EX(CloseHandleScope)
45 private:
46 HANDLE m_handle;
47 };
48
49 bool IsMenuNonEmpty(HMENU menu);
50 void SetDefaultMenuItem(HMENU p_menu, unsigned p_id);
51
52 void GetOSVersionString(pfc::string_base & out);
53 WORD GetOSVersionCode();
54 bool IsWine();
55 DWORD Win10BuildNumber(); // See https://en.wikipedia.org/wiki/Windows_10_version_history for build number reference
56
57 void EnumChildWindows(HWND, std::function<void(HWND)>); // Recursive
58 void EnumChildWindowsHere(HWND, std::function<void(HWND)>); // Non-recursive