diff options
author | chai <chaifix@163.com> | 2021-10-30 11:32:16 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-30 11:32:16 +0800 |
commit | 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce (patch) | |
tree | 24bc7009457a8d7500f264e89946dc20d069294f /Editor/Win | |
parent | 164885fd98d48703bd771f802d79557b7db97431 (diff) |
+ Penlight
Diffstat (limited to 'Editor/Win')
-rw-r--r-- | Editor/Win/Win.cpp | 65 | ||||
-rw-r--r-- | Editor/Win/Win.h | 25 |
2 files changed, 89 insertions, 1 deletions
diff --git a/Editor/Win/Win.cpp b/Editor/Win/Win.cpp index f6310e2..1081492 100644 --- a/Editor/Win/Win.cpp +++ b/Editor/Win/Win.cpp @@ -3,6 +3,17 @@ namespace Win { + static HINSTANCE s_InstanceHandle = NULL; + + HINSTANCE GetInstanceHandle() + { + if (s_InstanceHandle == NULL) + { + s_InstanceHandle = GetModuleHandle(NULL); + } + return s_InstanceHandle; + } + std::string GetCurrentWorkingDirectory() { char path[MAX_PATH]; @@ -15,4 +26,58 @@ namespace Win SetDllDirectory(path.c_str()); } + //https://stackoverflow.com/questions/59608898/how-to-get-the-state-of-the-cursor + //https://iwoohaha.tistory.com/archive/20080917 + void SetCursor(ECursor cursor) + { + LPCSTR name = IDC_ARROW; + switch (cursor) + { + case Win::Cursor_AppStarting: + name = IDC_APPSTARTING; + break; + case Win::Cursor_Arrow: + name = IDC_ARROW; + break; + case Win::Cursor_Cross: + name = IDC_CROSS; + break; + case Win::Cursor_Help: + name = IDC_HELP; + break; + case Win::Cursor_IBeam: + name = IDC_IBEAM; + break; + case Win::Cursor_NO: + name = IDC_NO; + break; + case Win::Cursor_SizeAll: + name = IDC_SIZEALL; + break; + case Win::Cursor_SizeNESW: + name = IDC_SIZENESW; + break; + case Win::Cursor_SizeNS: + name = IDC_SIZENS; + break; + case Win::Cursor_SizeNWSE: + name = IDC_SIZENWSE; + break; + case Win::Cursor_SizeWE: + name = IDC_SIZEWE; + break; + case Win::Cursor_UpArrow: + name = IDC_UPARROW; + break; + case Win::Cursor_Wait: + name = IDC_WAIT; + break; + default: + name = IDC_ARROW; + break; + } + HCURSOR hCursor = LoadCursorA(NULL, name); + ::SetCursor(hCursor); + } + }
\ No newline at end of file diff --git a/Editor/Win/Win.h b/Editor/Win/Win.h index 8d7d85d..a60cb83 100644 --- a/Editor/Win/Win.h +++ b/Editor/Win/Win.h @@ -8,6 +8,10 @@ namespace Win { + // 拿到当前程序的handle + HINSTANCE GetInstanceHandle(); + + // 当前工作目录 std::string GetCurrentWorkingDirectory(); void SetDllSearchDirectory(std::string path); @@ -18,4 +22,23 @@ namespace Win // 当前的执行是否在主线程 bool IsInMainThread(); -} + // 鼠标光标设置 + enum ECursor + { + Cursor_AppStarting, // 标准的箭头和小沙漏 + Cursor_Arrow, // 标准的箭头 + Cursor_Cross, // 十字光标 + Cursor_Help, // 标准的箭头和问号 + Cursor_IBeam, // 工字光标 + Cursor_NO, // 禁止圈 + Cursor_SizeAll, // 四向箭头指向东、西、南、北 + Cursor_SizeNESW, // 双箭头指向东北和西南 + Cursor_SizeNS, // 双箭头指向南北 + Cursor_SizeNWSE, // 双箭头指向西北和东南 + Cursor_SizeWE, // 双箭头指向东西 + Cursor_UpArrow, // 垂直箭头 + Cursor_Wait, // 沙漏 + }; + void SetCursor(ECursor cursor); + +}
\ No newline at end of file |