-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsDlg.cpp
More file actions
243 lines (213 loc) · 9.02 KB
/
Copy pathSettingsDlg.cpp
File metadata and controls
243 lines (213 loc) · 9.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
//
// MySETIviewer, a set tools for decoding bitstreams into various formats and manipulating those files
// SettingsDlg.cpp
// (C) 2023, Mark Stegall
// Author: Mark Stegall
//
// This file is part of MySETIviewer.
//
// MySETIviewer is free software : you can redistribute it and /or modify it under
// the terms of the GNU General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// MySETIviewer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with MySETIapp.
// If not, see < https://www.gnu.org/licenses/>.
//
// This file contains the dialog callback procedures for settings dialogs; Display and Layers
//
// V1.0.1 2023-12-20 Initial release
// V1.0.2 2023-12-20 Added Y direction flag for which direction to move image
// Separate Display and Layers dialogs from SettingsDlg file
// V1.1.1 2023-12-27 Added, Scale,Zoom ,pan settings
// Changed, moved .exe and .ini file information to About dialog
// Added, Show status bar flag
//
// Global Settings dialog box handler
//
#include "framework.h"
#include "MySETIviewer.h"
#include <libloaderapi.h>
#include <Windows.h>
#include <shobjidl.h>
#include <winver.h>
#include <vector>
#include <atlstr.h>
#include <strsafe.h>
#include <Commdlg.h>
#include "Display.h"
#include "Globals.h"
#include "imageheader.h"
#include "FileFunctions.h"
#include "Appfunctions.h"
//*******************************************************************************
//
// Message handler for SettingsGlobalDlg dialog box.
//
//*******************************************************************************
INT_PTR CALLBACK SettingsGlobalDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
WCHAR szString[MAX_PATH];
case WM_INITDIALOG:
{
int iRes;
GetPrivateProfileString(L"SettingsGlobalDlg", L"TempDir", L"", szString, MAX_PATH, (LPCTSTR)strAppNameINI);
SetDlgItemText(hDlg, IDC_IMG_TEMP, szString);
float sf, px, py;
ImgDlg->GetScalePos(&sf, &px, &py);
swprintf_s(szString, MAX_PATH, L"%.3f", sf);
SetDlgItemText(hDlg, IDC_SCALE_FACTOR, szString);
swprintf_s(szString, MAX_PATH, L"%.3f", px);
SetDlgItemText(hDlg, IDC_PAN_OFFSET_X, szString);
swprintf_s(szString, MAX_PATH, L"%.3f", py);
SetDlgItemText(hDlg, IDC_PAN_OFFSET_Y, szString);
// IDC_SETTINGS_AUTO_PNG
iRes = GetPrivateProfileInt(L"SettingsGlobalDlg", L"AutoPNG", 1, (LPCTSTR)strAppNameINI);
if (iRes != 0) {
CheckDlgButton(hDlg, IDC_SETTINGS_AUTO_PNG, BST_CHECKED);
}
// IDC_SETTINGS_START_LAST
iRes = GetPrivateProfileInt(L"SettingsGlobalDlg", L"StartLast", 0, (LPCTSTR)strAppNameINI);
if (iRes != 0) {
CheckDlgButton(hDlg, IDC_SETTINGS_START_LAST, BST_CHECKED);
}
// IDC_SETTINGS_STATUSBAR
iRes = GetPrivateProfileInt(L"SettingsGlobalDlg", L"ShowStatusBar", 1, (LPCTSTR)strAppNameINI);
if (iRes != 0) {
CheckDlgButton(hDlg, IDC_SETTINGS_STATUSBAR, BST_CHECKED);
}
// Radio buttons
int ydir = ImageLayers->GetYdir();
if (ydir) {
CheckRadioButton(hDlg, IDC_GLOBAL_YPOS_UP, IDC_GLOBAL_YPOS_DOWN, IDC_GLOBAL_YPOS_UP);
}
else {
CheckRadioButton(hDlg, IDC_GLOBAL_YPOS_UP, IDC_GLOBAL_YPOS_DOWN, IDC_GLOBAL_YPOS_DOWN);
}
if (KeepOpen) {
CheckRadioButton(hDlg, IDC_GLOBAL_KEEP_OPEN, IDC_GLOBAL_CLOSE_ON_OKCANCEL, IDC_GLOBAL_KEEP_OPEN);
}
else {
CheckRadioButton(hDlg, IDC_GLOBAL_KEEP_OPEN, IDC_GLOBAL_CLOSE_ON_OKCANCEL, IDC_GLOBAL_CLOSE_ON_OKCANCEL);
}
return (INT_PTR)TRUE;
}
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_IMG_TEMP_BROWSE:
{
PWSTR pszFilename;
GetDlgItemText(hDlg, IDC_IMG_TEMP, szString, MAX_PATH);
COMDLG_FILTERSPEC imgType[] =
{
{ L"All Files", L"*.*" } };
if (!CCFileOpen(hDlg, szString, &pszFilename, TRUE, 1, imgType, L"")) {
return (INT_PTR)TRUE;
}
{
wcscpy_s(szString, pszFilename);
CoTaskMemFree(pszFilename);
}
SetDlgItemText(hDlg, IDC_IMG_TEMP, szString);
return (INT_PTR)TRUE;
}
case IDOK:
{
int iRes;
float sf, px, py;
GetDlgItemText(hDlg, IDC_SCALE_FACTOR, szString, MAX_PATH);
iRes = swscanf_s(szString, L"%f", &sf);
if (iRes != 1) {
MessageBox(hDlg, L"Bad scale factor parameter", L"Globals", MB_OK);
return (INT_PTR)TRUE;
}
GetDlgItemText(hDlg, IDC_PAN_OFFSET_X, szString, MAX_PATH);
iRes = swscanf_s(szString, L"%f", &px);
if (iRes != 1) {
MessageBox(hDlg, L"Bad pan offset X parameter", L"Globals", MB_OK);
return (INT_PTR)TRUE;
}
GetDlgItemText(hDlg, IDC_PAN_OFFSET_Y, szString, MAX_PATH);
iRes = swscanf_s(szString, L"%f", &py);
if (iRes != 1) {
MessageBox(hDlg, L"Bad pan offset Y parameter", L"Globals", MB_OK);
return (INT_PTR)TRUE;
}
ImgDlg->SetScalePos(sf, px, py);
GetDlgItemText(hDlg, IDC_IMG_TEMP, szString, MAX_PATH);
size_t Length = wcslen(szString);
if (wcscmp(szString + Length - 1, L"\\") == 0) {
// If the last character is a backslash, delete
szString[Length - 1] = L'\0';
}
wcscpy_s(szTempDir, szString);
WritePrivateProfileString(L"SettingsGlobalDlg", L"TempDir", szString, (LPCTSTR)strAppNameINI);
// IDC_SETTINGS_AUTO_PNG
if (IsDlgButtonChecked(hDlg, IDC_SETTINGS_AUTO_PNG) == BST_CHECKED) {
WritePrivateProfileString(L"SettingsGlobalDlg", L"AutoPNG", L"1", (LPCTSTR)strAppNameINI);
AutoPNG = 1;
}
else {
WritePrivateProfileString(L"SettingsGlobalDlg", L"AutoPNG", L"0", (LPCTSTR)strAppNameINI);
AutoPNG = 0;
}
// IDC_SETTINGS_START_LAST
if (IsDlgButtonChecked(hDlg, IDC_SETTINGS_START_LAST) == BST_CHECKED) {
WritePrivateProfileString(L"SettingsGlobalDlg", L"StartLast", L"1", (LPCTSTR)strAppNameINI);
}
else {
WritePrivateProfileString(L"SettingsGlobalDlg", L"StartLast", L"0", (LPCTSTR)strAppNameINI);
}
// IDC_SETTINGS_STATUSBAR
if (IsDlgButtonChecked(hDlg, IDC_SETTINGS_STATUSBAR) == BST_CHECKED) {
WritePrivateProfileString(L"SettingsGlobalDlg", L"ShowStatusBar", L"1", (LPCTSTR)strAppNameINI);
ShowStatusBar = TRUE;
// create status bar
if (hwndImage && ImgDlg->StatusBarExists()) {
ImgDlg->ShowStatusBar(TRUE);
}
}
else {
WritePrivateProfileString(L"SettingsGlobalDlg", L"ShowStatusBar", L"0", (LPCTSTR)strAppNameINI);
ShowStatusBar = FALSE;
ImgDlg->ShowStatusBar(FALSE);
}
// radio buttons
if (IsDlgButtonChecked(hDlg, IDC_GLOBAL_YPOS_UP)) {
ImageLayers->SetYdir(1);
// (update the Layers dialog and apply to Image Window)
SendMessage(hwndLayers, WM_COMMAND, ID_UPDATE, 1);
WritePrivateProfileString(L"SettingsGlobalDlg", L"yposDir", L"1", (LPCTSTR)strAppNameINI);
}
else {
ImageLayers->SetYdir(0);
// (update the Layers dialog and apply to Image Window)
SendMessage(hwndLayers, WM_COMMAND, ID_UPDATE, 1);
WritePrivateProfileString(L"SettingsGlobalDlg", L"yposDir", L"0", (LPCTSTR)strAppNameINI);
}
if (IsDlgButtonChecked(hDlg, IDC_GLOBAL_KEEP_OPEN)) {
// This should set Display and Layers to to SW_SHOW
KeepOpen = TRUE;
WritePrivateProfileString(L"SettingsGlobalDlg", L"KeepOpen", L"1", (LPCTSTR)strAppNameINI);
}
else {
KeepOpen = FALSE;
WritePrivateProfileString(L"SettingsGlobalDlg", L"KeepOpen", L"0", (LPCTSTR)strAppNameINI);
}
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
case IDCANCEL:
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
}
}
return (INT_PTR)FALSE;
}