dl
dl_windows.h
浏览该文件的文档.
1
12#pragma once
13
14#if DL_PLATFORM == DL_PLATFORM_WIN32
15#include <string>
16#include <string_view>
17
18#include "system/dl_platform.h"
19#include "dl_type.h"
20
22namespace dl::Win32
23{
26 {
27 public:
28 SystemMutex(std::string_view name, size_t count);
30 operator bool() { return _free; }
31 private:
32 void* _mutex; // HANDLE
33 bool _free;
34 };
35
38
48 bool OpenUrl(std::string_view url,
49 std::string_view cmd = {},
50 std::string_view work_path = {});
51 // 常用路径检测文件是否存在
53 {
54 EWST_PROGRAM = 1 << 0, // Program Files
55 EWST_PROGRAM_X86 = 1 << 1, // Program Files (x86)
56 EWST_APPDATA_LOCAL = 1 << 2, // AppData/Local
57 EWST_PROGRAM_DATA = 1 << 3, // ProgramData
58 EWST_ALL = 0xffffffff
59 };
60
61 std::string SearchPathX(std::string_view path_child, int type);
66}
67
68#ifdef __AFX_H__
70namespace dl
71{
72 inline std::string to_string(const CStringA& str)
73 {
74 return { str.GetString(), str.GetString() + (size_t)str.GetLength() };
75 }
76 inline std::string to_string(const CStringW& str)
77 {
78 return CodeCvt::WideCharToUtf8(str.GetString());
79 }
80 inline CStringW to_CStringW(std::string_view str)
81 {
82 return CodeCvt::Utf8ToWideChar(str).c_str();
83 }
84 template<typename T>
85 std::string GetUIText(T& wnd)
86 {
87 CStringW str;
88 wnd.GetWindowTextW(str);
89 return CodeCvt::WideCharToUtf8(str.GetBuffer());
90 }
91 template<typename T>
92 void SetUIText(T& wnd, std::string_view str)
93 {
94 wnd.SetWindowTextW(CodeCvt::Utf8ToWideChar(str).c_str());
95 }
96 inline bool GetUICheck(CButton& btn)
97 {
98 return btn.GetCheck() == BST_CHECKED;
99 }
100 inline void SetUICheck(CButton& btn, bool select)
101 {
102 btn.SetCheck(select ? BST_CHECKED : BST_UNCHECKED);
103 }
104}
105#endif
106
107#endif
SystemMutex(std::string_view name, size_t count)
平台宏
通用类型
std::string WideCharToUtf8(std::wstring_view str)
字符串转换:宽字符 -> utf8
std::wstring Utf8ToWideChar(std::string_view str)
字符串转换:utf8 -> 宽字符
Windows平台接口
bool OpenUrl(std::string_view url, std::string_view cmd={}, std::string_view work_path={})
打开网页、文件夹、文件、程序
Size GetWorkArea()
返回工作区大小(请优先使用glfw)
Size GetDesktopSize()
返回桌面大小(请优先使用glfw)
std::string SearchPathX(std::string_view path_child, int type)
常见路径搜索
std::string to_string(T v)
to_string包装
PointU Size