Mercurial > msvpvf
annotate src/gui.c @ 15:69e9cd8817a7
Merge branch 'master' of github.com:mrpapersonic/msvpvf
| author | Paper <mrpapersonic@gmail.com> | 
|---|---|
| date | Tue, 01 Feb 2022 22:31:54 -0500 | 
| parents | 423aa3429d21 | 
| children | 812089083c89 | 
| rev | line source | 
|---|---|
| 6 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 1 #include <stdio.h> | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 2 #include <windows.h> | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 3 #include <stdint.h> | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 4 #include <stdbool.h> | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 5 #include <commdlg.h> | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 6 #define OPEN_FILE_BUTTON 0 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 7 #define COMBOBOX 1 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 8 #define LISTBOX 2 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 9 #define SAVE_FILE_BUTTON 3 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 10 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 11 HWND hWndListBox, hWndComboBox; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 12 int16_t version = 11, type = 1; /* type: 0 is vf, 1 is veg */ | 
| 9 | 13 char* file_name = " "; /* initialize as a space, a (windows) filename can't just be a space */ | 
| 6 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 14 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 15 void set_data(unsigned char magic[], uint16_t version, FILE* target) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 16 int i; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 17 fseek(target, 0x46, SEEK_SET); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 18 fputc(version, target); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 19 for (i=0; i<=sizeof(*magic); ++i) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 20 fseek(target, 0x18+i, SEEK_SET); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 21 fputc(magic[i], target); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 22 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 23 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 24 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 25 int copy_file(char* source_file, char* target_file) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 26 FILE *source, *target; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 27 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 28 source = fopen(source_file, "rb"); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 29 if (source == NULL) return 1; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 30 target = fopen(target_file, "wb"); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 31 if (target == NULL) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 32 fclose(source); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 33 return 1; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 34 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 35 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 36 size_t n, m; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 37 unsigned char buff[8192]; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 38 do { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 39 n = fread(buff, 1, sizeof(buff), source); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 40 if (n) m = fwrite(buff, 1, n, target); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 41 else m = 0; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 42 } while ((n > 0) && (n == m)); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 43 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 44 fclose(target); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 45 fclose(source); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 46 return 0; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 47 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 48 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 49 void display_file(char* path) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 50 /* Read the file to memory */ | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 51 FILE* file; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 52 file = fopen(path, "rb"); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 53 fseek(file, 0, SEEK_END); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 54 int _size = ftell(file); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 55 rewind(file); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 56 char* data = calloc(_size+1, sizeof(char*)); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 57 fread(data, _size, 1, file); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 58 data[_size] = '\0'; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 59 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 60 free(data); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 61 fclose(file); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 62 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 63 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 64 char* open_file(HWND hWnd) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 65 OPENFILENAME ofn; | 
| 9 | 66 char filename[256]; | 
| 6 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 67 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 68 ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 69 ofn.lStructSize = sizeof(OPENFILENAME); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 70 ofn.hwndOwner = hWnd; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 71 ofn.lpstrFile = filename; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 72 ofn.lpstrFile[0] = '\0'; | 
| 9 | 73 ofn.nMaxFile = 256; | 
| 6 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 74 ofn.lpstrFilter = "Project files\0*.veg;*.vf\0All files\0*.*\0"; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 75 ofn.nFilterIndex = 1; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 76 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 77 GetOpenFileName(&ofn); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 78 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 79 display_file(filename); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 80 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 81 return _strdup(filename); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 82 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 83 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 84 void save_file(HWND hWnd, char* input_file) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 85 if (strcmp(input_file, " ") == 0) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 86 MessageBoxW(hWnd, L"Please open a file first!", L"Invalid input file!", MB_ICONEXCLAMATION); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 87 return; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 88 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 89 OPENFILENAME ofn; | 
| 9 | 90 char output_file[256]; | 
| 6 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 91 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 92 ZeroMemory(&ofn, sizeof(OPENFILENAME)); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 93 ofn.lStructSize = sizeof(OPENFILENAME); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 94 ofn.hwndOwner = hWnd; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 95 ofn.lpstrFile = output_file; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 96 ofn.lpstrFile[0] = '\0'; | 
| 9 | 97 ofn.nMaxFile = 256; | 
| 6 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 98 ofn.lpstrFilter = "Project files\0*.veg\0All files\0*.*\0"; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 99 ofn.nFilterIndex = 1; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 100 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 101 GetSaveFileName(&ofn); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 102 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 103 copy_file(input_file, output_file); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 104 FILE* output = fopen(output_file, "r+b"); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 105 if (output == NULL) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 106 MessageBoxW(hWnd, L"Failed to save project file!", L"Saving project failed!", MB_ICONEXCLAMATION); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 107 return; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 108 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 109 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 110 if (type == 1) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 111 unsigned char magic[] = {0xEF, 0x29, 0xC4, 0x46, 0x4A, 0x90, 0xD2, 0x11, 0x87, 0x22, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A}; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 112 set_data(magic, version, output); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 113 } else { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 114 unsigned char magic[] = {0xF6, 0x1B, 0x3C, 0x53, 0x35, 0xD6, 0xF3, 0x43, 0x8A, 0x90, 0x64, 0xB8, 0x87, 0x23, 0x1F, 0x7F}; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 115 set_data(magic, version, output); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 116 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 117 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 118 fclose(output); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 119 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 120 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 121 void AddControls(HWND hWnd) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 122 /* versions */ | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 123 hWndComboBox = CreateWindowW(L"ComboBox", NULL, CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_CHILD | WS_VISIBLE | WS_OVERLAPPED | WS_VSCROLL, (int)((225 - 50)/2), 30, 50, 200, hWnd, (HMENU)COMBOBOX, NULL, NULL); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 124 TCHAR versions[][10] = {TEXT("8"), TEXT("9"), TEXT("10"), TEXT("11"), TEXT("12"), TEXT("13"), TEXT("14"), TEXT("15"), TEXT("16"), TEXT("17"), TEXT("18"), TEXT("19")}; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 125 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 126 TCHAR A[16]; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 127 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 128 memset(&A,0,sizeof(A)); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 129 int i = 0; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 130 for (i = 0; i <= 11; i++) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 131 wcscpy_s((WCHAR*)A, sizeof(A)/sizeof(TCHAR), (WCHAR*)versions[i]); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 132 SendMessage(hWndComboBox, (UINT)CB_ADDSTRING, (WPARAM)0, (LPARAM)A); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 133 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 134 SendMessage(hWndComboBox, CB_SETCURSEL, (WPARAM)3, (LPARAM)0); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 135 /* open file */ | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 136 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); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 137 /* type */ | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 138 TCHAR listbox_items[][13] = {TEXT("VEGAS Pro"), TEXT("Movie Studio")}; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 139 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); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 140 for (i = 0; i < ARRAYSIZE(listbox_items); i++) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 141 int pos = (int)SendMessage(hWndListBox, LB_ADDSTRING, i, (LPARAM) listbox_items[i]); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 142 SendMessage(hWndListBox, LB_SETITEMDATA, pos, (LPARAM) i); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 143 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 144 SendMessage(hWndListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 145 /* save file */ | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 146 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); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 147 if (open_button == NULL || save_button == NULL || hWndListBox == NULL || hWndComboBox == NULL) | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 148 MessageBoxW(hWnd, L"how did you even trigger this", L"GUI could not be initialized!", MB_ICONEXCLAMATION); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 149 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 150 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 151 bool CALLBACK SetFont(HWND child, LPARAM font) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 152 SendMessage(child, WM_SETFONT, font, true); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 153 return true; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 154 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 155 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 156 LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 157 switch(msg) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 158 case WM_COMMAND: | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 159 if(HIWORD(wParam) == CBN_SELCHANGE) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 160 if (LOWORD(wParam) == COMBOBOX) | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 161 version = (int16_t)(8+SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0)); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 162 if (LOWORD(wParam) == LISTBOX) | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 163 type = SendMessage((HWND) lParam, (UINT) LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 164 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 165 switch(wParam) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 166 case OPEN_FILE_BUTTON: | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 167 file_name = open_file(hWnd); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 168 break; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 169 case COMBOBOX: | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 170 break; /* NOTE: remove these 4 lines if we don't end up doing anything with them */ | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 171 case LISTBOX: | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 172 break; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 173 case SAVE_FILE_BUTTON: | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 174 save_file(hWnd, file_name); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 175 break; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 176 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 177 break; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 178 case WM_CREATE: { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 179 AddControls(hWnd); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 180 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 | 181 break; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 182 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 183 case WM_DESTROY: | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 184 PostQuitMessage(0); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 185 break; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 186 default: | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 187 return DefWindowProcW(hWnd, msg, wParam, lParam); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 188 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 189 return false; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 190 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 191 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 192 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR args, int ncmdshow) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 193 WNDCLASSW wc = {0}; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 194 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 195 wc.hbrBackground = (HBRUSH)COLOR_WINDOW; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 196 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 197 wc.hInstance = hInstance; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 198 wc.lpszClassName = L"msvpvf"; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 199 wc.lpfnWndProc = WindowProcedure; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 200 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 201 if (!RegisterClassW(&wc)) return -1; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 202 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 203 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); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 204 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 205 MSG msg = {0}; | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 206 | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 207 while (GetMessage(&msg, NULL, 0, 0)) { | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 208 TranslateMessage(&msg); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 209 DispatchMessage(&msg); | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 210 } | 
| 
d1e5b8390cd3
Add Windows GUI version and a multitude of other changes
 Paper <mrpapersonic@gmail.com> parents: diff
changeset | 211 } | 
