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
35 bool OpenUrl(std::string_view url,
36 std::string_view cmd = {},
37 std::string_view work_path = {});
38 // 常用路径检测文件是否存在
40 {
41 EWST_PROGRAM = 1 << 0, // Program Files
42 EWST_PROGRAM_X86 = 1 << 1, // Program Files (x86)
43 EWST_APPDATA_LOCAL = 1 << 2, // AppData/Local
44 EWST_PROGRAM_DATA = 1 << 3, // ProgramData
45 EWST_ALL = 0xffffffff
46 };
48 std::string SearchPathX(std::string_view path_child, int type);
53}
54
55#ifdef __AFX_H__
57namespace dl
58{
59 inline std::string to_string(const CStringA& str)
60 {
61 return { str.GetString(), str.GetString() + (size_t)str.GetLength() };
62 }
63 inline std::string to_string(const CStringW& str)
64 {
65 return CodeCvt::WideCharToUtf8(str.GetString());
66 }
67 inline CStringW to_CStringW(std::string_view str)
68 {
69 return CodeCvt::Utf8ToWideChar(str).c_str();
70 }
71 template<typename T>
72 std::string GetUIText(T& wnd)
73 {
74 CStringW str;
75 wnd.GetWindowTextW(str);
76 return CodeCvt::WideCharToUtf8(str.GetBuffer());
77 }
78 template<typename T>
79 void SetUIText(T& wnd, std::string_view str)
80 {
81 wnd.SetWindowTextW(CodeCvt::Utf8ToWideChar(str).c_str());
82 }
83 inline bool GetUICheck(CButton& btn)
84 {
85 return btn.GetCheck() == BST_CHECKED;
86 }
87 inline void SetUICheck(CButton& btn, bool select)
88 {
89 btn.SetCheck(select ? BST_CHECKED : BST_UNCHECKED);
90 }
91}
92#endif
93
94#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)
WindowsSearchType
Definition: dl_windows.h:40
@ EWST_PROGRAM_X86
Definition: dl_windows.h:42
@ EWST_PROGRAM_DATA
Definition: dl_windows.h:44
@ EWST_APPDATA_LOCAL
Definition: dl_windows.h:43
@ EWST_PROGRAM
Definition: dl_windows.h:41
std::string SearchPathX(std::string_view path_child, int type)
常见路径搜索
Definition: dl_array2.h:18
PointU Size
Definition: dl_type_def.h:34
std::string to_string(const SpriteID &id)
Definition: dl_sprite.h:50