Mercurial > msvpvf
comparison src/gui.c @ 88:af4ed765c1ac
*: add IUP GUI
a lot simpler than win32, but I assume there's more going on in
the background that I don't know about :)
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 14 Jul 2025 02:39:24 -0400 |
| parents | c06dcab17923 |
| children | 42a1f64eb4b5 |
comparison
equal
deleted
inserted
replaced
| 87:2e819b84d7c0 | 88:af4ed765c1ac |
|---|---|
| 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 */ | |
| 17 | 15 |
| 18 #include "common.h" | 16 #include "common.h" |
| 19 | 17 |
| 20 /* make sure this is defined... */ | 18 /* make sure this is defined... */ |
| 21 #ifndef _MAX_ULTOSTR_BASE10_COUNT | 19 #ifndef _MAX_ULTOSTR_BASE10_COUNT |
| 32 LISTBOX, | 30 LISTBOX, |
| 33 SAVE_FILE_BUTTON, | 31 SAVE_FILE_BUTTON, |
| 34 VERSION | 32 VERSION |
| 35 }; | 33 }; |
| 36 | 34 |
| 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 | |
| 44 /* user-adjustable. set these values to whatever you want, the GUI will scale */ | 35 /* user-adjustable. set these values to whatever you want, the GUI will scale */ |
| 45 #define WINDOW_WIDTH 225U | 36 #define WINDOW_WIDTH 225U |
| 46 #define WINDOW_HEIGHT 200U | 37 #define WINDOW_HEIGHT 200U |
| 47 | 38 |
| 48 static LPTSTR file_path = NULL; | 39 static LPTSTR file_path = NULL; |
| 118 | 109 |
| 119 IFileDialog* pfd = NULL; | 110 IFileDialog* pfd = NULL; |
| 120 IShellItem* result = NULL; | 111 IShellItem* result = NULL; |
| 121 | 112 |
| 122 if (SUCCEEDED(CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileOpenDialog, (LPVOID*)&pfd))) { | 113 if (SUCCEEDED(CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileOpenDialog, (LPVOID*)&pfd))) { |
| 123 pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters); | 114 pfd->lpVtbl->SetFileTypes(pfd, ARRAY_SIZE(filters), filters); |
| 124 pfd->lpVtbl->SetFileTypeIndex(pfd, 1); | 115 pfd->lpVtbl->SetFileTypeIndex(pfd, 1); |
| 125 pfd->lpVtbl->Show(pfd, hWnd); | 116 pfd->lpVtbl->Show(pfd, hWnd); |
| 126 | 117 |
| 127 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result)) || !result) { | 118 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result)) || !result) { |
| 128 pfd->lpVtbl->Release(pfd); | 119 pfd->lpVtbl->Release(pfd); |
| 194 COMDLG_FILTERSPEC filters[] = {{L"Movie Studio project files", L"*.vf"}, {L"Vegas Pro project files", L"*.veg"}, {L"All files", L"*.*"}}; | 185 COMDLG_FILTERSPEC filters[] = {{L"Movie Studio project files", L"*.vf"}, {L"Vegas Pro project files", L"*.veg"}, {L"All files", L"*.*"}}; |
| 195 | 186 |
| 196 IFileDialog* pfd = NULL; | 187 IFileDialog* pfd = NULL; |
| 197 IShellItem* result = NULL; | 188 IShellItem* result = NULL; |
| 198 if (com_initialized && SUCCEEDED(CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSaveDialog, (LPVOID*)&pfd))) { | 189 if (com_initialized && SUCCEEDED(CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSaveDialog, (LPVOID*)&pfd))) { |
| 199 pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters); | 190 pfd->lpVtbl->SetFileTypes(pfd, ARRAY_SIZE(filters), filters); |
| 200 pfd->lpVtbl->SetFileTypeIndex(pfd, (type == TYPES_UNKNOWN) ? ARRAYSIZE(filters) : type - TYPES_UNKNOWN); | 191 pfd->lpVtbl->SetFileTypeIndex(pfd, (type == TYPES_UNKNOWN) ? ARRAY_SIZE(filters) : type - TYPES_UNKNOWN); |
| 201 pfd->lpVtbl->SetFileName(pfd, output_template); | 192 pfd->lpVtbl->SetFileName(pfd, output_template); |
| 202 pfd->lpVtbl->Show(pfd, hWnd); | 193 pfd->lpVtbl->Show(pfd, hWnd); |
| 203 | 194 |
| 204 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result))) { | 195 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result))) { |
| 205 pfd->lpVtbl->Release(pfd); | 196 pfd->lpVtbl->Release(pfd); |
| 289 } | 280 } |
| 290 | 281 |
| 291 /* Type */ | 282 /* Type */ |
| 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); | 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); |
| 293 | 284 |
| 294 for (size_t i = 0; i < ARRAYSIZE(types); i++) { | 285 for (size_t i = 0; i < ARRAY_SIZE(types); i++) { |
| 295 LRESULT pos = SendMessage(listbox, LB_ADDSTRING, i, (LPARAM)type_to_string(types[i])); | 286 LRESULT pos = SendMessage(listbox, LB_ADDSTRING, i, (LPARAM)type_to_string(types[i])); |
| 296 SendMessage(listbox, LB_SETITEMDATA, pos, types[i]); | 287 SendMessage(listbox, LB_SETITEMDATA, pos, types[i]); |
| 297 if (types[i] == type) | 288 if (types[i] == type) |
| 298 SendMessage(listbox, LB_SETCURSEL, pos, 0); | 289 SendMessage(listbox, LB_SETCURSEL, pos, 0); |
| 299 } | 290 } |
| 373 return 0; | 364 return 0; |
| 374 } | 365 } |
| 375 | 366 |
| 376 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { | 367 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { |
| 377 WNDCLASS wc = {0}; | 368 WNDCLASS wc = {0}; |
| 369 MSG msg = {0}; | |
| 378 | 370 |
| 379 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; | 371 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; |
| 380 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 372 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
| 381 wc.hInstance = hInstance; | 373 wc.hInstance = hInstance; |
| 382 wc.lpszClassName = TEXT("msvpvf"); | 374 wc.lpszClassName = TEXT("msvpvf"); |
| 384 | 376 |
| 385 if (!RegisterClass(&wc)) return -1; | 377 if (!RegisterClass(&wc)) return -1; |
| 386 | 378 |
| 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); | 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); |
| 388 | 380 |
| 389 MSG msg = {0}; | |
| 390 | |
| 391 while (GetMessage(&msg, NULL, 0, 0)) { | 381 while (GetMessage(&msg, NULL, 0, 0)) { |
| 392 TranslateMessage(&msg); | 382 TranslateMessage(&msg); |
| 393 DispatchMessage(&msg); | 383 DispatchMessage(&msg); |
| 394 } | 384 } |
| 395 return 0; | 385 return 0; |
