Sun, 01 Oct 2023 17:22:17 +0200
add toggle switch (WinUI3)
180
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | #include "util.h" |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | #include <stdlib.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | #include <Windows.h> |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | wchar_t* str2wstr(const char* str, int* newlen) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | size_t len = strlen(str); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | wchar_t* wstr = (wchar_t*)calloc(len + 1, sizeof(wchar_t)); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | int wlen = MultiByteToWideChar( |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | CP_UTF8, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | 0, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | str, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | len, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | wstr, |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | len + 1 |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | ); |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | if (newlen) { |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | *newlen = wlen; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | } |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | wstr[wlen] = 0; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | return wstr; |
f34953bf4ac7
add basic winui menu implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | } |