changeset 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
files src/gui.c
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui.c	Mon Jul 14 02:39:24 2025 -0400
+++ b/src/gui.c	Mon Jul 14 02:41:25 2025 -0400
@@ -13,6 +13,8 @@
 #include <stdint.h>
 #include <stdio.h>
 
+#include <tchar.h> /* tchar versions of string.h functions */
+
 #include "common.h"
 
 /* make sure this is defined... */
@@ -32,6 +34,13 @@
 	VERSION
 };
 
+#if UNICODE
+/* use COM when `UNICODE=1` to avoid file paths being cut off */
+#include <shobjidl.h>
+
+static const DWORD COM_INITFLAGS = (COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+#endif
+
 /* user-adjustable. set these values to whatever you want, the GUI will scale */
 #define WINDOW_WIDTH  225U
 #define WINDOW_HEIGHT 200U
@@ -111,7 +120,7 @@
 	IShellItem* result = NULL;
 
 	if (SUCCEEDED(CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileOpenDialog, (LPVOID*)&pfd))) {
-		pfd->lpVtbl->SetFileTypes(pfd, ARRAY_SIZE(filters), filters);
+		pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters);
 		pfd->lpVtbl->SetFileTypeIndex(pfd, 1);
 		pfd->lpVtbl->Show(pfd, hWnd);
 
@@ -187,8 +196,8 @@
 		IFileDialog* pfd = NULL;
 		IShellItem* result = NULL;
 		if (com_initialized && SUCCEEDED(CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSaveDialog, (LPVOID*)&pfd))) {
-			pfd->lpVtbl->SetFileTypes(pfd, ARRAY_SIZE(filters), filters);
-			pfd->lpVtbl->SetFileTypeIndex(pfd, (type == TYPES_UNKNOWN) ? ARRAY_SIZE(filters) : type - TYPES_UNKNOWN);
+			pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters);
+			pfd->lpVtbl->SetFileTypeIndex(pfd, (type == TYPES_UNKNOWN) ? ARRAYSIZE(filters) : type - TYPES_UNKNOWN);
 			pfd->lpVtbl->SetFileName(pfd, output_template);
 			pfd->lpVtbl->Show(pfd, hWnd);
 
@@ -282,7 +291,7 @@
 	/* Type */
 	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);
 
-	for (size_t i = 0; i < ARRAY_SIZE(types); i++) {
+	for (size_t i = 0; i < ARRAYSIZE(types); i++) {
 		LRESULT pos = SendMessage(listbox, LB_ADDSTRING, i, (LPARAM)type_to_string(types[i]));
 		SendMessage(listbox, LB_SETITEMDATA, pos, types[i]);
 		if (types[i] == type)
@@ -366,7 +375,6 @@
 
 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) {
 	WNDCLASS wc = {0};
-	MSG msg = {0};
 
 	wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
 	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
@@ -378,6 +386,8 @@
 
 	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);
 
+	MSG msg = {0};
+
 	while (GetMessage(&msg, NULL, 0, 0)) {
 		TranslateMessage(&msg);
 		DispatchMessage(&msg);