dl
dl_windows.h
浏览该文件的文档.
1
12#pragma once
13
14#if DL_PLATFORM == DL_PLATFORM_WIN32
15#include <string>
16
17#include "system/dl_platform.h"
18#include "dl_type.h"
19
20namespace dl::Win32
21{
24 {
25 public:
26 SystemMutex(std::string_view name);
28 operator bool() { return _has; }
29 private:
30 void* _mutex; // HANDLE
31 bool _has;
32 };
33
36
46 bool OpenUrl(std::string_view url,
47 std::string_view cmd = {},
48 std::string_view work_path = {});
49 // 常用路径检测文件是否存在
51 {
52 EWST_PROGRAM = 1 << 0, // Program Files
53 EWST_PROGRAM_X86 = 1 << 1, // Program Files (x86)
54 EWST_APPDATA_LOCAL = 1 << 2, // AppData/Local
55 EWST_PROGRAM_DATA = 1 << 3, // ProgramData
56 EWST_ALL = 0xffffffff
57 };
58
59 std::string SearchPathX(std::string_view path_child, int type);
64}
65
66#ifdef __AFX_H__
68namespace dl
69{
70 inline std::string to_string(const CStringA& str)
71 {
72 return { str.GetString(), str.GetString() + (size_t)str.GetLength() };
73 }
74 inline std::string to_string(const CStringW& str)
75 {
76 return CodeCvt::WideCharToUtf8(str.GetString());
77 }
78 inline CStringW to_CStringW(std::string_view str)
79 {
80 return CodeCvt::Utf8ToWideChar(str).c_str();
81 }
82 template<typename T>
83 std::string GetUIText(T& wnd)
84 {
85 CStringW str;
86 wnd.GetWindowTextW(str);
87 return CodeCvt::WideCharToUtf8(str.GetBuffer());
88 }
89 template<typename T>
90 void SetUIText(T& wnd, std::string_view str)
91 {
92 wnd.SetWindowTextW(CodeCvt::Utf8ToWideChar(str).c_str());
93 }
94 inline bool GetUICheck(CButton& btn)
95 {
96 return btn.GetCheck() == BST_CHECKED;
97 }
98 inline void SetUICheck(CButton& btn, bool select)
99 {
100 btn.SetCheck(select ? BST_CHECKED : BST_UNCHECKED);
101 }
102}
103#endif
104
105#endif
SystemMutex(std::string_view name)
平台宏
通用类型
std::string WideCharToUtf8(std::wstring_view str)
字符串转换:宽字符 -> utf8
std::wstring Utf8ToWideChar(std::string_view str)
字符串转换:utf8 -> 宽字符
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