summaryrefslogtreecommitdiff
path: root/Editor/Win/Win.cpp
blob: 10814925113c362487ec49f74c36dd92c2a65722 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "win.h"

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];
		GetCurrentDirectory(MAX_PATH, path);
		return path;
	}

	void SetDllSearchDirectory(std::string path)
	{
		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);
	}

}