1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* MPTrackUtil.h
* -------------
* Purpose: Various useful utility functions.
* Notes : (currently none)
* Authors: OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#pragma once
#include "openmpt/all/BuildSettings.hpp"
#include <string>
OPENMPT_NAMESPACE_BEGIN
bool CreateShellFolderLink(const mpt::PathString &path, const mpt::PathString &target, const mpt::ustring &description = mpt::ustring());
bool CreateShellFileLink(const mpt::PathString &path, const mpt::PathString &target, const mpt::ustring &description = mpt::ustring());
/*
* Gets resource as raw byte data.
* [in] lpName and lpType: parameters passed to FindResource().
* Return: span representing the resource data, valid as long as hInstance is valid.
*/
mpt::const_byte_span GetResource(LPCTSTR lpName, LPCTSTR lpType);
CString LoadResourceString(UINT nID);
namespace Util
{
// Get horizontal DPI resolution
MPT_FORCEINLINE int GetDPIx(HWND hwnd)
{
HDC dc = ::GetDC(hwnd);
int dpi = ::GetDeviceCaps(dc, LOGPIXELSX);
::ReleaseDC(hwnd, dc);
return dpi;
}
// Get vertical DPI resolution
MPT_FORCEINLINE int GetDPIy(HWND hwnd)
{
HDC dc = ::GetDC(hwnd);
int dpi = ::GetDeviceCaps(dc, LOGPIXELSY);
::ReleaseDC(hwnd, dc);
return dpi;
}
// Applies DPI scaling factor to some given size
MPT_FORCEINLINE int ScalePixels(int pixels, HWND hwnd)
{
return MulDiv(pixels, GetDPIx(hwnd), 96);
}
// Removes DPI scaling factor from some given size
MPT_FORCEINLINE int ScalePixelsInv(int pixels, HWND hwnd)
{
return MulDiv(pixels, 96, GetDPIx(hwnd));
}
}
namespace Util
{
inline DWORD64 GetTickCount64()
{
#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
return ::GetTickCount64();
#else
return ::GetTickCount();
#endif
}
}
OPENMPT_NAMESPACE_END
|