Mercurial > msvpvf
comparison src/gui.c @ 89:42a1f64eb4b5 default tip
gui: fix build fail
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 14 Jul 2025 02:41:25 -0400 |
| parents | af4ed765c1ac |
| children |
comparison
equal
deleted
inserted
replaced
| 88:af4ed765c1ac | 89:42a1f64eb4b5 |
|---|---|
| 10 #include <winbase.h> | 10 #include <winbase.h> |
| 11 #include <shlwapi.h> | 11 #include <shlwapi.h> |
| 12 | 12 |
| 13 #include <stdint.h> | 13 #include <stdint.h> |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 | |
| 16 #include <tchar.h> /* tchar versions of string.h functions */ | |
| 15 | 17 |
| 16 #include "common.h" | 18 #include "common.h" |
| 17 | 19 |
| 18 /* make sure this is defined... */ | 20 /* make sure this is defined... */ |
| 19 #ifndef _MAX_ULTOSTR_BASE10_COUNT | 21 #ifndef _MAX_ULTOSTR_BASE10_COUNT |
| 30 LISTBOX, | 32 LISTBOX, |
| 31 SAVE_FILE_BUTTON, | 33 SAVE_FILE_BUTTON, |
| 32 VERSION | 34 VERSION |
| 33 }; | 35 }; |
| 34 | 36 |
| 37 #if UNICODE | |
| 38 /* use COM when `UNICODE=1` to avoid file paths being cut off */ | |
| 39 #include <shobjidl.h> | |
| 40 | |
| 41 static const DWORD COM_INITFLAGS = (COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); | |
| 42 #endif | |
| 43 | |
| 35 /* user-adjustable. set these values to whatever you want, the GUI will scale */ | 44 /* user-adjustable. set these values to whatever you want, the GUI will scale */ |
| 36 #define WINDOW_WIDTH 225U | 45 #define WINDOW_WIDTH 225U |
| 37 #define WINDOW_HEIGHT 200U | 46 #define WINDOW_HEIGHT 200U |
| 38 | 47 |
| 39 static LPTSTR file_path = NULL; | 48 static LPTSTR file_path = NULL; |
| 109 | 118 |
| 110 IFileDialog* pfd = NULL; | 119 IFileDialog* pfd = NULL; |
| 111 IShellItem* result = NULL; | 120 IShellItem* result = NULL; |
| 112 | 121 |
| 113 if (SUCCEEDED(CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileOpenDialog, (LPVOID*)&pfd))) { | 122 if (SUCCEEDED(CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileOpenDialog, (LPVOID*)&pfd))) { |
| 114 pfd->lpVtbl->SetFileTypes(pfd, ARRAY_SIZE(filters), filters); | 123 pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters); |
| 115 pfd->lpVtbl->SetFileTypeIndex(pfd, 1); | 124 pfd->lpVtbl->SetFileTypeIndex(pfd, 1); |
| 116 pfd->lpVtbl->Show(pfd, hWnd); | 125 pfd->lpVtbl->Show(pfd, hWnd); |
| 117 | 126 |
| 118 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result)) || !result) { | 127 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result)) || !result) { |
| 119 pfd->lpVtbl->Release(pfd); | 128 pfd->lpVtbl->Release(pfd); |
| 185 COMDLG_FILTERSPEC filters[] = {{L"Movie Studio project files", L"*.vf"}, {L"Vegas Pro project files", L"*.veg"}, {L"All files", L"*.*"}}; | 194 COMDLG_FILTERSPEC filters[] = {{L"Movie Studio project files", L"*.vf"}, {L"Vegas Pro project files", L"*.veg"}, {L"All files", L"*.*"}}; |
| 186 | 195 |
| 187 IFileDialog* pfd = NULL; | 196 IFileDialog* pfd = NULL; |
| 188 IShellItem* result = NULL; | 197 IShellItem* result = NULL; |
| 189 if (com_initialized && SUCCEEDED(CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSaveDialog, (LPVOID*)&pfd))) { | 198 if (com_initialized && SUCCEEDED(CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSaveDialog, (LPVOID*)&pfd))) { |
| 190 pfd->lpVtbl->SetFileTypes(pfd, ARRAY_SIZE(filters), filters); | 199 pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters); |
| 191 pfd->lpVtbl->SetFileTypeIndex(pfd, (type == TYPES_UNKNOWN) ? ARRAY_SIZE(filters) : type - TYPES_UNKNOWN); | 200 pfd->lpVtbl->SetFileTypeIndex(pfd, (type == TYPES_UNKNOWN) ? ARRAYSIZE(filters) : type - TYPES_UNKNOWN); |
| 192 pfd->lpVtbl->SetFileName(pfd, output_template); | 201 pfd->lpVtbl->SetFileName(pfd, output_template); |
| 193 pfd->lpVtbl->Show(pfd, hWnd); | 202 pfd->lpVtbl->Show(pfd, hWnd); |
| 194 | 203 |
| 195 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result))) { | 204 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result))) { |
| 196 pfd->lpVtbl->Release(pfd); | 205 pfd->lpVtbl->Release(pfd); |
| 280 } | 289 } |
| 281 | 290 |
| 282 /* Type */ | 291 /* Type */ |
| 283 HWND listbox = CreateWindow(TEXT("Listbox"), NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, WINDOW_WIDTH * 5 / 18, WINDOW_HEIGHT * 11 / 40, WINDOW_WIDTH * 4 / 9, WINDOW_HEIGHT / 5, hWnd, (HMENU)LISTBOX, NULL, NULL); | 292 HWND listbox = CreateWindow(TEXT("Listbox"), NULL, WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_NOTIFY, WINDOW_WIDTH * 5 / 18, WINDOW_HEIGHT * 11 / 40, WINDOW_WIDTH * 4 / 9, WINDOW_HEIGHT / 5, hWnd, (HMENU)LISTBOX, NULL, NULL); |
| 284 | 293 |
| 285 for (size_t i = 0; i < ARRAY_SIZE(types); i++) { | 294 for (size_t i = 0; i < ARRAYSIZE(types); i++) { |
| 286 LRESULT pos = SendMessage(listbox, LB_ADDSTRING, i, (LPARAM)type_to_string(types[i])); | 295 LRESULT pos = SendMessage(listbox, LB_ADDSTRING, i, (LPARAM)type_to_string(types[i])); |
| 287 SendMessage(listbox, LB_SETITEMDATA, pos, types[i]); | 296 SendMessage(listbox, LB_SETITEMDATA, pos, types[i]); |
| 288 if (types[i] == type) | 297 if (types[i] == type) |
| 289 SendMessage(listbox, LB_SETCURSEL, pos, 0); | 298 SendMessage(listbox, LB_SETCURSEL, pos, 0); |
| 290 } | 299 } |
| 364 return 0; | 373 return 0; |
| 365 } | 374 } |
| 366 | 375 |
| 367 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { | 376 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { |
| 368 WNDCLASS wc = {0}; | 377 WNDCLASS wc = {0}; |
| 369 MSG msg = {0}; | |
| 370 | 378 |
| 371 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; | 379 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; |
| 372 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 380 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 373 wc.hInstance = hInstance; | 381 wc.hInstance = hInstance; |
| 374 wc.lpszClassName = TEXT("msvpvf"); | 382 wc.lpszClassName = TEXT("msvpvf"); |
| 376 | 384 |
| 377 if (!RegisterClass(&wc)) return -1; | 385 if (!RegisterClass(&wc)) return -1; |
| 378 | 386 |
| 379 CreateWindowEx(WS_EX_ACCEPTFILES, TEXT("msvpvf"), TEXT("Movie Studio / Vegas Pro version spoofer"), WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL); | 387 CreateWindowEx(WS_EX_ACCEPTFILES, TEXT("msvpvf"), TEXT("Movie Studio / Vegas Pro version spoofer"), WS_OVERLAPPED | WS_VISIBLE | WS_MINIMIZEBOX | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, hInstance, NULL); |
| 380 | 388 |
| 389 MSG msg = {0}; | |
| 390 | |
| 381 while (GetMessage(&msg, NULL, 0, 0)) { | 391 while (GetMessage(&msg, NULL, 0, 0)) { |
| 382 TranslateMessage(&msg); | 392 TranslateMessage(&msg); |
| 383 DispatchMessage(&msg); | 393 DispatchMessage(&msg); |
| 384 } | 394 } |
| 385 return 0; | 395 return 0; |
