HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
utility.hpp
1// Copyright Take Vos 2023.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
8#include "../macros.hpp"
9#include <utility>
10#include <cstdint>
11#include <Windows.h>
12
13hi_export_module(hikogui.win32 : utility);
14
15hi_export namespace hi { inline namespace v1 {
16
25[[nodiscard]] inline uint32_t win32_HANDLE_to_int(HANDLE handle) noexcept
26{
27 auto i = std::bit_cast<uintptr_t>(handle);
28 if (std::cmp_greater(i, std::numeric_limits<uint32_t>::max())) {
30 }
31 return static_cast<uint32_t>(i);
32}
33
34[[nodiscard]] inline HANDLE win32_int_to_HANDLE(uint32_t i) noexcept
35{
36 return std::bit_cast<HANDLE>(static_cast<uintptr_t>(i));
37}
38
39}} // namespace hi::v1
Rules for working with win32 headers.
The HikoGUI namespace.
Definition array_generic.hpp:20
uint32_t win32_HANDLE_to_int(HANDLE handle) noexcept
Convert a HANDLE to a 32-bit unsigned integer.
Definition utility.hpp:25
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
T terminate(T... args)