aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/mptrack/MPTrackUtil.h
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/mptrack/MPTrackUtil.h
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/mptrack/MPTrackUtil.h')
-rw-r--r--Src/external_dependencies/openmpt-trunk/mptrack/MPTrackUtil.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/mptrack/MPTrackUtil.h b/Src/external_dependencies/openmpt-trunk/mptrack/MPTrackUtil.h
new file mode 100644
index 00000000..ff0eab59
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/mptrack/MPTrackUtil.h
@@ -0,0 +1,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