Mercurial > msvpvf
annotate src/gui.c @ 80:719570851563
Added tag v2.0 for changeset 8f90d5addda9
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 20 Mar 2024 17:09:43 -0400 |
parents | 8f90d5addda9 |
children | c06dcab17923 |
rev | line source |
---|---|
18
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
1 /** |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
2 * msvpvf GUI for Windows |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
3 * Copyright (c) Paper 2022-2024 |
18
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
4 * |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
5 * Permission is hereby granted, free of charge, to any person obtaining a copy |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
6 * of this software and associated documentation files (the "Software"), to deal |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
7 * in the Software without restriction, including without limitation the rights |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
9 * copies of the Software, and to permit persons to whom the Software is |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
10 * furnished to do so, subject to the following conditions: |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
11 * |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
12 * The above copyright notice and this permission notice shall be included in all |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
13 * copies or substantial portions of the Software. |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
14 * |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
21 * SOFTWARE. |
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
22 **/ |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
23 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
24 /* change these macros to configure the window size */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
25 #define WINDOW_WIDTH 225 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
26 #define WINDOW_HEIGHT 200 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
27 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
28 /* mingw */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
29 #ifdef UNICODE |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
30 #define NTDDI_VERSION 0x06000000 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
31 #define _WIN32_WINNT 0x0600 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
32 #else |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
33 #define _WIN32_WINNT 0x0400 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
34 #endif |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
35 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
36 #include <windef.h> |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
37 #include <winbase.h> |
68
207684d44b54
gui.c: Add drag and drop support
Paper <mrpapersonic@gmail.com>
parents:
63
diff
changeset
|
38 #include <shlwapi.h> |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
39 #include <shobjidl.h> |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
40 |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
41 #include <stdint.h> |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
42 #include <stdio.h> |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
43 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
44 #include "common.h" |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
45 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
46 /* we use COM when `UNICODE=1` to avoid file paths being cut off */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
47 #define COM_INITFLAGS (COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE) |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
48 |
58
fcd4b9fe957b
[gui.c]: show version and type in a box
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
56
diff
changeset
|
49 #define OPEN_FILE_BUTTON 0 |
fcd4b9fe957b
[gui.c]: show version and type in a box
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
56
diff
changeset
|
50 #define COMBOBOX 1 |
fcd4b9fe957b
[gui.c]: show version and type in a box
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
56
diff
changeset
|
51 #define LISTBOX 2 |
fcd4b9fe957b
[gui.c]: show version and type in a box
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
56
diff
changeset
|
52 #define SAVE_FILE_BUTTON 3 |
fcd4b9fe957b
[gui.c]: show version and type in a box
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
56
diff
changeset
|
53 #define VERSION 4 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
54 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
55 /* adjust for these functions for Unicode */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
56 #if UNICODE |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
57 #define _tstrncpy wcsncpy |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
58 #define _tstrdup _wcsdup |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
59 #define _tfopen _wfopen |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
60 #define _sntprintf _snwprintf |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
61 #else |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
62 #define _tstrncpy strncpy |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
63 #define _tstrdup _strdup |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
64 #define _tfopen fopen |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
65 #define _sntprintf _snprintf |
39
b32218b54640
Use ANSI instead of Unicode (Windows 95 support)
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
38
diff
changeset
|
66 #endif |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
67 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
68 /* enumerate over this */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
69 static const enum types types[] = {TYPES_VF, TYPES_VEG}; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
70 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
71 static LPTSTR file_path = NULL; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
72 static uint8_t version = 13; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
73 static enum types type = TYPES_VEG; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
74 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
75 /* we edit this from display_file() */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
76 static HWND hwnd_version = NULL; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
77 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
78 static inline LPCTSTR type_to_prefix(enum types type) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
79 switch (type) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
80 case TYPES_VF: return TEXT("MS"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
81 case TYPES_VEG: return TEXT("PRO"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
82 case TYPES_UNKNOWN: |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
83 default: return TEXT("UNK"); |
58
fcd4b9fe957b
[gui.c]: show version and type in a box
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
56
diff
changeset
|
84 } |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
85 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
86 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
87 static inline LPCTSTR type_to_string(enum types type) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
88 switch (type) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
89 case TYPES_VF: return TEXT("Movie Studio"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
90 case TYPES_VEG: return TEXT("Vegas Pro"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
91 case TYPES_UNKNOWN: |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
92 default: return TEXT("Unknown"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
93 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
94 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
95 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
96 static inline LPCTSTR type_to_extension(enum types type) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
97 switch (type) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
98 case TYPES_VF: return TEXT("vf"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
99 case TYPES_VEG: |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
100 case TYPES_UNKNOWN: |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
101 default: return TEXT("veg"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
102 } |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
103 } |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
104 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
105 /* these functions are designed to *not* use global variables, |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
106 * to make everything a bit more simple... */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
107 static int display_file(LPCTSTR path) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
108 /* Read the file to memory */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
109 FILE* file = _tfopen(path, TEXT("rb")); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
110 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
111 uint8_t file_version = 0; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
112 enum types file_type = TYPES_UNKNOWN; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
113 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
114 get_file_information(file, &file_version, &file_type); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
115 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
116 int needed = _sntprintf(NULL, 0, TEXT("File version: %s %u"), type_to_string(file_type), file_version); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
117 LPTSTR text = calloc(needed + 1, sizeof(TCHAR)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
118 if (!text) /* out of memory... lol */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
119 exit(1); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
120 _sntprintf(text, needed + 1, TEXT("File version: %s %u"), type_to_string(file_type), file_version); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
121 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
122 if (!SendMessage(hwnd_version, WM_SETTEXT, (WPARAM)0, (LPARAM)text)) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
123 free(text); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
124 return -1; |
38
161ec4e87d0a
Crash fix for Windows 2000 and XP
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
34
diff
changeset
|
125 } |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
126 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
127 free(text); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
128 fclose(file); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
129 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
130 return 0; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
131 } |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
132 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
133 static int open_file(HWND hWnd, LPTSTR* filepath) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
134 #if UNICODE |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
135 if (CoInitializeEx(NULL, COM_INITFLAGS) != S_OK) |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
136 return -1; /* what */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
137 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
138 COMDLG_FILTERSPEC filters[] = {{L"Project files", L"*.veg;*.vf"}, {L"All files", L"*.*"}}; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
139 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
140 IFileDialog* pfd = NULL; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
141 IShellItem* result = NULL; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
142 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
143 if (SUCCEEDED(CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileOpenDialog, (LPVOID*)&pfd))) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
144 pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
145 pfd->lpVtbl->SetFileTypeIndex(pfd, 1); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
146 pfd->lpVtbl->Show(pfd, hWnd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
147 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
148 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result)) || !result) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
149 pfd->lpVtbl->Release(pfd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
150 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
151 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
152 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
153 if (!SUCCEEDED(result->lpVtbl->GetDisplayName(result, SIGDN_FILESYSPATH, filepath))) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
154 pfd->lpVtbl->Release(pfd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
155 result->lpVtbl->Release(result); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
156 *filepath = NULL; /* might memleak? */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
157 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
158 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
159 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
160 result->lpVtbl->Release(result); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
161 pfd->lpVtbl->Release(pfd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
162 } else { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
163 #endif |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
164 /* initialize our buffer */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
165 *filepath = calloc(MAX_PATH + 1, sizeof(TCHAR)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
166 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
167 OPENFILENAME ofn = {0}; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
168 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
169 /* NT 4.0 compat */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
170 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
171 ofn.hwndOwner = hWnd; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
172 ofn.lpstrFile = *filepath; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
173 ofn.nMaxFile = MAX_PATH; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
174 ofn.lpstrFilter = TEXT("Project files\0*.veg;*.vf\0All files\0*.*\0"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
175 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
176 if (!GetOpenFileName(&ofn)) |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
177 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
178 #if UNICODE |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
179 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
180 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
181 CoUninitialize(); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
182 #endif |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
183 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
184 return display_file(*filepath);; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
185 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
186 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
187 static int save_file(HWND hWnd, LPCTSTR input, uint8_t version, enum types type) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
188 if (!input) { |
52
cf9a14755472
Use Win32 libraries to copy files
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
51
diff
changeset
|
189 MessageBox(hWnd, |
cf9a14755472
Use Win32 libraries to copy files
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
51
diff
changeset
|
190 TEXT("Please open a file first!"), |
cf9a14755472
Use Win32 libraries to copy files
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
51
diff
changeset
|
191 TEXT("Invalid input file!"), |
cf9a14755472
Use Win32 libraries to copy files
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
51
diff
changeset
|
192 MB_ICONEXCLAMATION); |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
193 return -1; |
38
161ec4e87d0a
Crash fix for Windows 2000 and XP
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
34
diff
changeset
|
194 } |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
195 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
196 LPTSTR output_template = NULL; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
197 LPTSTR output = NULL; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
198 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
199 { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
200 LPTSTR input_basename = PathFindFileName(input); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
201 int input_basename_len = PathFindExtension(input_basename) - input_basename; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
202 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
203 int needed = _sntprintf(NULL, 0, TEXT("%s_V%u_%.*s.%s"), type_to_prefix(type), version, input_basename_len, input_basename, type_to_extension(type)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
204 output_template = calloc(needed + 1, sizeof(TCHAR)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
205 _sntprintf(output_template, needed + 1, TEXT("%s_V%u_%.*s.%s"), type_to_prefix(type), version, input_basename_len, input_basename, type_to_extension(type)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
206 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
207 free(input_basename); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
208 } |
68
207684d44b54
gui.c: Add drag and drop support
Paper <mrpapersonic@gmail.com>
parents:
63
diff
changeset
|
209 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
210 { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
211 /* File dialog */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
212 #if UNICODE |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
213 int com_initialized = SUCCEEDED(CoInitializeEx(NULL, COM_INITFLAGS)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
214 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
215 COMDLG_FILTERSPEC filters[] = {{L"Movie Studio project files", L"*.vf"}, {L"Vegas Pro project files", L"*.veg"}, {L"All files", L"*.*"}}; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
216 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
217 IFileDialog* pfd = NULL; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
218 IShellItem* result = NULL; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
219 if (com_initialized && SUCCEEDED(CoCreateInstance(&CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileSaveDialog, (LPVOID*)&pfd))) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
220 pfd->lpVtbl->SetFileTypes(pfd, ARRAYSIZE(filters), filters); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
221 pfd->lpVtbl->SetFileTypeIndex(pfd, (type == TYPES_UNKNOWN) ? ARRAYSIZE(filters) : type - TYPES_UNKNOWN); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
222 pfd->lpVtbl->SetFileName(pfd, output_template); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
223 pfd->lpVtbl->Show(pfd, hWnd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
224 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
225 if (!SUCCEEDED(pfd->lpVtbl->GetResult(pfd, &result))) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
226 pfd->lpVtbl->Release(pfd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
227 free(output_template); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
228 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
229 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
230 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
231 if (!SUCCEEDED(result->lpVtbl->GetDisplayName(result, SIGDN_FILESYSPATH, &output))) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
232 pfd->lpVtbl->Release(pfd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
233 result->lpVtbl->Release(result); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
234 free(output_template); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
235 output = NULL; /* might memleak ? */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
236 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
237 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
238 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
239 result->lpVtbl->Release(result); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
240 pfd->lpVtbl->Release(pfd); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
241 free(output_template); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
242 } else { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
243 #endif |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
244 /* fallback to OPENFILENAME if COM fucks up for whatever reason (or we're on ANSI)... */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
245 output = calloc(MAX_PATH + 1, sizeof(TCHAR)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
246 _tstrncpy(output, output_template, MAX_PATH); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
247 free(output_template); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
248 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
249 OPENFILENAME ofn = {0}; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
250 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
251 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
252 ofn.hwndOwner = hWnd; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
253 ofn.lpstrFile = output; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
254 ofn.nMaxFile = MAX_PATH; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
255 ofn.lpstrFilter = TEXT("Movie Studio project files\0*.vf\0Vegas Pro project files\0*.veg\0All files\0*.*\0"); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
256 ofn.nFilterIndex = (type == TYPES_UNKNOWN) ? 3 : type - TYPES_UNKNOWN; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
257 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
258 if (!GetSaveFileName(&ofn)) |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
259 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
260 #if UNICODE |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
261 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
262 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
263 if (com_initialized) |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
264 CoUninitialize(); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
265 #endif |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
266 } |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
267 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
268 if (!CopyFile(input, output, 0)) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
269 MessageBox(hWnd, TEXT("Failed to copy original project file! Does the destination file already exist?"), TEXT("Saving project failed!"), MB_ICONEXCLAMATION | MB_OK); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
270 free(output); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
271 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
272 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
273 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
274 FILE* output_file = _tfopen(output, TEXT("ab")); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
275 if (!output_file) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
276 MessageBox(hWnd, TEXT("Failed to save project file!"), TEXT("Saving project failed!"), MB_ICONEXCLAMATION | MB_OK); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
277 free(output); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
278 return -1; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
279 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
280 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
281 free(output); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
282 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
283 set_file_information(output_file, version, type); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
284 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
285 fclose(output_file); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
286 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
287 return 0; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
288 } |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
289 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
290 /* TODO: use a resource file instead... */ |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
291 void AddControls(HWND hWnd) { |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
292 /* Open File */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
293 HWND open_button = CreateWindow(TEXT("Button"), TEXT("Open"), WS_VISIBLE | WS_CHILD, WINDOW_WIDTH * 7 / 18, WINDOW_HEIGHT / 40, WINDOW_WIDTH * 2 / 9, WINDOW_HEIGHT / 10, hWnd, (HMENU)OPEN_FILE_BUTTON, NULL, NULL); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
294 |
18
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
295 /* Versions */ |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
296 HWND combobox = CreateWindow(TEXT("ComboBox"), NULL, |
18
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
297 CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_VSCROLL, |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
298 WINDOW_WIDTH * 7 / 18, WINDOW_HEIGHT * 3 / 20, WINDOW_WIDTH * 2 / 9, WINDOW_HEIGHT, |
68
207684d44b54
gui.c: Add drag and drop support
Paper <mrpapersonic@gmail.com>
parents:
63
diff
changeset
|
299 hWnd, (HMENU)COMBOBOX, NULL, NULL); |
207684d44b54
gui.c: Add drag and drop support
Paper <mrpapersonic@gmail.com>
parents:
63
diff
changeset
|
300 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
301 static LPCTSTR versions[] = {TEXT("8"), TEXT("9"), TEXT("10"), |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
302 TEXT("11"), TEXT("12"), TEXT("13"), |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
303 TEXT("14"), TEXT("15"), TEXT("16"), |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
304 TEXT("17"), TEXT("18"), TEXT("19"), |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
305 TEXT("20"), TEXT("21")}; /* wuss 9+10 */ |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
306 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
307 for (size_t i = 0; i < ARRAYSIZE(versions); i++) |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
308 SendMessage(combobox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)versions[i]); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
309 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
310 SendMessage(combobox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
311 |
18
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
312 /* Type */ |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
313 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); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
314 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
315 for (size_t i = 0; i < ARRAYSIZE(types); i++) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
316 LRESULT pos = SendMessage(listbox, LB_ADDSTRING, i, (LPARAM)type_to_string(types[i])); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
317 SendMessage(listbox, LB_SETITEMDATA, pos, (LPARAM)types[i]); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
318 if (types[i] == type) |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
319 SendMessage(listbox, LB_SETCURSEL, (WPARAM)pos, (LPARAM)0); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
320 } |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
321 |
18
b5df3f47a30e
Use enums for `type`
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
17
diff
changeset
|
322 /* Save File */ |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
323 HWND save_button = CreateWindow(TEXT("Button"), TEXT("Save"), WS_VISIBLE | WS_CHILD, WINDOW_WIDTH * 7 / 18, WINDOW_HEIGHT * 9 / 20, WINDOW_WIDTH * 2 / 9, WINDOW_HEIGHT / 10, hWnd, (HMENU)SAVE_FILE_BUTTON, NULL, NULL); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
324 |
58
fcd4b9fe957b
[gui.c]: show version and type in a box
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
56
diff
changeset
|
325 /* Version and Type display */ |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
326 hwnd_version = CreateWindow(TEXT("Edit"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_BORDER | ES_READONLY | ES_CENTER | ES_MULTILINE | SS_CENTER, WINDOW_WIDTH / 6, WINDOW_HEIGHT * 3 / 5, WINDOW_WIDTH * 2 / 3, WINDOW_HEIGHT / 5, hWnd, (HMENU)VERSION, NULL, NULL); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
327 if (!open_button || !save_button || !listbox || !combobox || !hwnd_version) |
52
cf9a14755472
Use Win32 libraries to copy files
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
51
diff
changeset
|
328 MessageBox(hWnd, TEXT("how did you even trigger this"), TEXT("GUI could not be initialized!"), MB_ICONEXCLAMATION); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
329 } |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
330 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
331 int CALLBACK SetFont(HWND child, LPARAM font) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
332 SendMessage(child, WM_SETFONT, font, 1); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
333 return 1; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
334 } |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
335 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
336 LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
337 switch(msg) { |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
338 case WM_COMMAND: |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
339 if (HIWORD(wParam) == CBN_SELCHANGE) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
340 switch (LOWORD(wParam)) { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
341 case COMBOBOX: |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
342 version = (uint8_t)(8+SendMessage((HWND)lParam, (UINT)CB_GETCURSEL, (WPARAM)0, (LPARAM)0)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
343 break; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
344 case LISTBOX: { |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
345 LRESULT i = SendMessage((HWND)lParam, (UINT)LB_GETCURSEL, (WPARAM)0, (LPARAM)0); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
346 type = (enum types)SendMessage((HWND)lParam, (UINT)LB_GETITEMDATA, (WPARAM)i, (LPARAM)0); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
347 break; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
348 } |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
349 default: |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
350 break; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
351 } |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
352 } |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
353 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
354 switch (wParam) { |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
355 case OPEN_FILE_BUTTON: |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
356 /* free(NULL) == no-op */ |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
357 free(file_path); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
358 open_file(hWnd, &file_path); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
359 break; |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
360 case SAVE_FILE_BUTTON: |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
361 save_file(hWnd, file_path, version, type); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
362 break; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
363 default: |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
364 break; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
365 } |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
366 break; |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
367 case WM_CREATE: |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
368 AddControls(hWnd); |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
369 EnumChildWindows(hWnd, (WNDENUMPROC)SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT)); |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
370 break; |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
371 case WM_DESTROY: |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
372 PostQuitMessage(0); |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
373 break; |
69
79a35af2cb56
gui.c: Add angled brackets around case
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
68
diff
changeset
|
374 case WM_DROPFILES: { |
68
207684d44b54
gui.c: Add drag and drop support
Paper <mrpapersonic@gmail.com>
parents:
63
diff
changeset
|
375 /* Drag and drop support */ |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
376 free(file_path); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
377 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
378 HDROP drop = (HDROP)wParam; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
379 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
380 int needed = DragQueryFile(drop, 0, NULL, 0); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
381 file_path = malloc((needed + 1) * sizeof(TCHAR)); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
382 DragQueryFile(drop, 0, file_path, needed + 1); |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
383 file_path[needed] = L'\0'; |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
384 |
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
385 display_file(file_path); |
68
207684d44b54
gui.c: Add drag and drop support
Paper <mrpapersonic@gmail.com>
parents:
63
diff
changeset
|
386 break; |
69
79a35af2cb56
gui.c: Add angled brackets around case
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
68
diff
changeset
|
387 } |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
388 default: |
51
0f6c604b6863
We don't need to specify that it's ANSI
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
47
diff
changeset
|
389 return DefWindowProc(hWnd, msg, wParam, lParam); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
390 } |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
391 return 0; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
392 } |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
393 |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
394 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { |
51
0f6c604b6863
We don't need to specify that it's ANSI
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
47
diff
changeset
|
395 WNDCLASS wc = {0}; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
396 |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
397 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
398 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
399 wc.hInstance = hInstance; |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
400 wc.lpszClassName = TEXT("msvpvf"); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
401 wc.lpfnWndProc = WindowProcedure; |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
402 |
51
0f6c604b6863
We don't need to specify that it's ANSI
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
47
diff
changeset
|
403 if (!RegisterClass(&wc)) return -1; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
404 |
79
8f90d5addda9
*: refactor... basically everything!
Paper <paper@paper.us.eu.org>
parents:
69
diff
changeset
|
405 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); |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
406 |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
407 MSG msg = {0}; |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
408 |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
409 while (GetMessage(&msg, NULL, 0, 0)) { |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
410 TranslateMessage(&msg); |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
411 DispatchMessage(&msg); |
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
412 } |
39
b32218b54640
Use ANSI instead of Unicode (Windows 95 support)
Paper <37962225+mrpapersonic@users.noreply.github.com>
parents:
38
diff
changeset
|
413 return 0; |
6
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
414 } |