Mercurial > msvpvf
comparison src/gui.c @ 39:b32218b54640
Use ANSI instead of Unicode (Windows 95 support)
I don't know why I used Unicode in the first place :p
author | Paper <37962225+mrpapersonic@users.noreply.github.com> |
---|---|
date | Fri, 22 Apr 2022 02:08:59 -0400 |
parents | 161ec4e87d0a |
children | cd50c59286be |
comparison
equal
deleted
inserted
replaced
38:161ec4e87d0a | 39:b32218b54640 |
---|---|
25 #include <stdio.h> | 25 #include <stdio.h> |
26 #include <windows.h> | 26 #include <windows.h> |
27 #include <stdint.h> | 27 #include <stdint.h> |
28 #include <stdbool.h> | 28 #include <stdbool.h> |
29 #include <commdlg.h> | 29 #include <commdlg.h> |
30 #define _WIN32_WINNT 0x0400 | |
31 #define ARRAYSIZE(a) \ | |
32 sizeof(a)/sizeof(a[0]) | |
30 #define OPEN_FILE_BUTTON 0 | 33 #define OPEN_FILE_BUTTON 0 |
31 #define COMBOBOX 1 | 34 #define COMBOBOX 1 |
32 #define LISTBOX 2 | 35 #define LISTBOX 2 |
33 #define SAVE_FILE_BUTTON 3 | 36 #define SAVE_FILE_BUTTON 3 |
37 #ifdef _MSC_VER | |
38 #define strdup(p) _strdup(p) | |
39 #endif | |
34 | 40 |
35 HWND hWndListBox, hWndComboBox; | 41 HWND hWndListBox, hWndComboBox; |
36 int16_t version = 13; | 42 int16_t version = 13; |
37 enum types { | 43 enum types { |
38 vf, | 44 vf, |
89 free(data); | 95 free(data); |
90 fclose(file); | 96 fclose(file); |
91 } | 97 } |
92 | 98 |
93 char* open_file(HWND hWnd) { | 99 char* open_file(HWND hWnd) { |
94 OPENFILENAME ofn; | 100 OPENFILENAMEA ofn; |
95 char filename[256]; | 101 char filename[256]; |
96 | 102 |
97 ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 103 ZeroMemory(&ofn, OPENFILENAME_SIZE_VERSION_400); |
98 ofn.lStructSize = sizeof(OPENFILENAME); | 104 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; |
99 ofn.hwndOwner = hWnd; | 105 ofn.hwndOwner = hWnd; |
100 ofn.lpstrFile = filename; | 106 ofn.lpstrFile = filename; |
101 ofn.lpstrFile[0] = '\0'; | 107 ofn.lpstrFile[0] = '\0'; |
102 ofn.nMaxFile = 256; | 108 ofn.nMaxFile = 256; |
103 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0"; | 109 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0"; |
107 return " "; | 113 return " "; |
108 } | 114 } |
109 | 115 |
110 display_file(filename); | 116 display_file(filename); |
111 | 117 |
112 return _strdup(filename); | 118 return strdup(filename); |
113 } | 119 } |
114 | 120 |
115 void save_file(HWND hWnd, char* input_file) { | 121 void save_file(HWND hWnd, char* input_file) { |
116 if (strcmp(input_file, " ") == 0) { | 122 if (strcmp(input_file, " ") == 0) { |
117 MessageBoxW(hWnd, | 123 MessageBoxA(hWnd, |
118 L"Please open a file first!", | 124 "Please open a file first!", |
119 L"Invalid input file!", | 125 "Invalid input file!", |
120 MB_ICONEXCLAMATION); | 126 MB_ICONEXCLAMATION); |
121 return; | 127 return; |
122 } | 128 } |
123 OPENFILENAME ofn; | 129 OPENFILENAMEA ofn; |
124 char output_file[256]; | 130 char output_file[256]; |
125 | 131 |
126 ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 132 ZeroMemory(&ofn, OPENFILENAME_SIZE_VERSION_400); |
127 ofn.lStructSize = sizeof(OPENFILENAME); | 133 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; |
128 ofn.hwndOwner = hWnd; | 134 ofn.hwndOwner = hWnd; |
129 ofn.lpstrFile = output_file; | 135 ofn.lpstrFile = output_file; |
130 ofn.lpstrFile[0] = '\0'; | 136 ofn.lpstrFile[0] = '\0'; |
131 ofn.nMaxFile = 256; | 137 ofn.nMaxFile = 256; |
132 ofn.lpstrFilter = "Movie Studio project files\0*.vf\0VEGAS Pro project files\0*.veg\0All files\0*.*\0"; | 138 ofn.lpstrFilter = "Movie Studio project files\0*.vf\0VEGAS Pro project files\0*.veg\0All files\0*.*\0"; |
137 } | 143 } |
138 | 144 |
139 copy_file(input_file, output_file); | 145 copy_file(input_file, output_file); |
140 FILE* output = fopen(output_file, "r+b"); | 146 FILE* output = fopen(output_file, "r+b"); |
141 if (output == NULL) { | 147 if (output == NULL) { |
142 MessageBoxW(hWnd, L"Failed to save project file!", L"Saving project failed!", MB_ICONEXCLAMATION); | 148 MessageBoxA(hWnd, "Failed to save project file!", "Saving project failed!", MB_ICONEXCLAMATION); |
143 return; | 149 return; |
144 } | 150 } |
145 | 151 |
146 switch ((int)type) { | 152 switch ((int)type) { |
147 case vf: { | 153 case vf: { |
161 fclose(output); | 167 fclose(output); |
162 } | 168 } |
163 | 169 |
164 void AddControls(HWND hWnd) { | 170 void AddControls(HWND hWnd) { |
165 /* Versions */ | 171 /* Versions */ |
166 hWndComboBox = CreateWindowW(L"ComboBox", NULL, | 172 hWndComboBox = CreateWindowA("ComboBox", NULL, |
167 CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_VSCROLL, | 173 CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_VSCROLL, |
168 (int)((225 - 50)/2), 30, 50, 200, | 174 (int)((225 - 50)/2), 30, 50, 200, |
169 hWnd, (HMENU)COMBOBOX, NULL, NULL); /** | 175 hWnd, (HMENU)COMBOBOX, NULL, NULL); /** |
170 * I don't understand what half of | 176 * I don't understand what half of |
171 * these arguments are for, so chances | 177 * these arguments are for, so chances |
185 * small to figure it out. | 191 * small to figure it out. |
186 **/ | 192 **/ |
187 memset(&A,0,sizeof(A)); | 193 memset(&A,0,sizeof(A)); |
188 int i = 0; | 194 int i = 0; |
189 for (i = 0; i <= 11; i++) { | 195 for (i = 0; i <= 11; i++) { |
190 wcscpy_s((WCHAR*)A, sizeof(A)/sizeof(TCHAR), (WCHAR*)versions[i]); | 196 strncpy((TCHAR*)A, (TCHAR*)versions[i], ARRAYSIZE(A); |
191 SendMessage(hWndComboBox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)A); | 197 SendMessage(hWndComboBox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)A); |
192 } | 198 } |
193 SendMessage(hWndComboBox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0); | 199 SendMessage(hWndComboBox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0); |
194 /* Open File */ | 200 /* Open File */ |
195 HWND open_button = CreateWindowW(L"Button", L"Open", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 5, 50, 20, hWnd, (HMENU)OPEN_FILE_BUTTON, NULL, NULL); | 201 HWND open_button = CreateWindowA("Button", "Open", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 5, 50, 20, hWnd, (HMENU)OPEN_FILE_BUTTON, NULL, NULL); |
196 /* Type */ | 202 /* Type */ |
197 TCHAR listbox_items[][13] = {TEXT("VEGAS Pro"), TEXT("Movie Studio")}; | 203 TCHAR listbox_items[][13] = {TEXT("VEGAS Pro"), TEXT("Movie Studio")}; |
198 hWndListBox = CreateWindowW(L"Listbox", NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, (int)((225 - 100)/2), 55, 100, 40, hWnd, (HMENU)LISTBOX, NULL, NULL); | 204 hWndListBox = CreateWindowA("Listbox", NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, (int)((225 - 100)/2), 55, 100, 40, hWnd, (HMENU)LISTBOX, NULL, NULL); |
199 for (i = 0; i < ARRAYSIZE(listbox_items); i++) { | 205 for (i = 0; i < ARRAYSIZE(listbox_items); i++) { |
200 int pos = (int)SendMessage(hWndListBox, LB_ADDSTRING, i, (LPARAM) listbox_items[i]); | 206 int pos = (int)SendMessage(hWndListBox, LB_ADDSTRING, i, (LPARAM) listbox_items[i]); |
201 SendMessage(hWndListBox, LB_SETITEMDATA, pos, (LPARAM) i); | 207 SendMessage(hWndListBox, LB_SETITEMDATA, pos, (LPARAM) i); |
202 } | 208 } |
203 SendMessage(hWndListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0); | 209 SendMessage(hWndListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0); |
204 /* Save File */ | 210 /* Save File */ |
205 HWND save_button = CreateWindowW(L"Button", L"Save", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 90, 50, 20, hWnd, (HMENU)SAVE_FILE_BUTTON, NULL, NULL); | 211 HWND save_button = CreateWindowA("Button", "Save", WS_VISIBLE | WS_CHILD, (int)((225 - 50)/2), 90, 50, 20, hWnd, (HMENU)SAVE_FILE_BUTTON, NULL, NULL); |
206 if (open_button == NULL || save_button == NULL || hWndListBox == NULL || hWndComboBox == NULL) | 212 if (open_button == NULL || save_button == NULL || hWndListBox == NULL || hWndComboBox == NULL) |
207 MessageBoxW(hWnd, L"how did you even trigger this", L"GUI could not be initialized!", MB_ICONEXCLAMATION); | 213 MessageBoxA(hWnd, "how did you even trigger this", "GUI could not be initialized!", MB_ICONEXCLAMATION); |
208 } | 214 } |
209 | 215 |
210 bool CALLBACK SetFont(HWND child, LPARAM font) { | 216 bool CALLBACK SetFont(HWND child, LPARAM font) { |
211 SendMessage(child, WM_SETFONT, font, true); | 217 SendMessage(child, WM_SETFONT, font, true); |
212 return true; | 218 return true; |
241 } | 247 } |
242 case WM_DESTROY: | 248 case WM_DESTROY: |
243 PostQuitMessage(0); | 249 PostQuitMessage(0); |
244 break; | 250 break; |
245 default: | 251 default: |
246 return DefWindowProcW(hWnd, msg, wParam, lParam); | 252 return DefWindowProcA(hWnd, msg, wParam, lParam); |
247 } | 253 } |
248 return false; | 254 return false; |
249 } | 255 } |
250 | 256 |
251 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { | 257 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { |
252 WNDCLASSW wc = {0}; | 258 WNDCLASSA wc = {0}; |
253 | 259 |
254 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; | 260 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; |
255 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 261 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
256 wc.hInstance = hInstance; | 262 wc.hInstance = hInstance; |
257 wc.lpszClassName = L"msvpvf"; | 263 wc.lpszClassName = "msvpvf"; |
258 wc.lpfnWndProc = WindowProcedure; | 264 wc.lpfnWndProc = WindowProcedure; |
259 | 265 |
260 if (!RegisterClassW(&wc)) return -1; | 266 if (!RegisterClassA(&wc)) return -1; |
261 | 267 |
262 CreateWindowW(L"msvpvf", L"Movie Studio / Vegas Pro version spoofer", WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, 100, 100, 225, 200, NULL, NULL, hInstance, NULL); | 268 CreateWindowA("msvpvf", "Movie Studio / Vegas Pro version spoofer", WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, 100, 100, 225, 200, NULL, NULL, hInstance, NULL); |
263 | 269 |
264 MSG msg = {0}; | 270 MSG msg = {0}; |
265 | 271 |
266 while (GetMessage(&msg, NULL, 0, 0)) { | 272 while (GetMessage(&msg, NULL, 0, 0)) { |
267 TranslateMessage(&msg); | 273 TranslateMessage(&msg); |
268 DispatchMessage(&msg); | 274 DispatchMessage(&msg); |
269 } | 275 } |
270 } | 276 return 0; |
277 } |