source: trunk/dll/archive.c@ 1203

Last change on this file since 1203 was 1203, checked in by John Small, 17 years ago

Ticket 187: Move datadevlarations/definitions out of fm3dll.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.6 KB
RevLine 
[123]1
2/***********************************************************************
3
4 $Id: archive.c 1203 2008-09-13 06:46:02Z jbs $
5
6 Archive create/update dialog procedure
7
8 Copyright (c) 1993-98 M. Kimes
[318]9 Copyright (c) 2004, 2006 Steven H.Levine
[123]10
[318]11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 28 Jun 06 SHL Drop obsoletes
[342]13 17 Jul 06 SHL Use Runtime_Error
[574]14 22 Mar 07 GKY Use QWL_USER
[793]15 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[123]16
17***********************************************************************/
18
[907]19#include <string.h>
20
[2]21#define INCL_WIN
22#define INCL_DOS
[907]23#define INCL_LONGLONG // dircnrs.h
[2]24
[1179]25#include "fm3dll.h"
[1203]26#include "notebook.h" // Data declaration(s)
[2]27#include "fm3dlg.h"
28#include "fm3str.h"
[907]29#include "strutil.h" // GetPString
30#include "errutil.h" // Runtime_Error
[1179]31#include "archive.h"
32#include "systemf.h" // ExecOnList
33#include "chklist.h" // PosOverOkay
34#include "getnames.h" // export_filename
35#include "misc.h" // PaintRecessedWindow
36#include "strips.h" // bstrip
[2]37
[342]38static PSZ pszSrcFile = __FILE__;
39
[551]40MRESULT EXPENTRY ArchiveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[123]41{
[551]42 DIRCNRDATA *arcdata = NULL;
[2]43
[551]44 switch (msg) {
45 case WM_INITDLG:
[574]46 WinSetWindowPtr(hwnd, QWL_USER, mp2);
[551]47 arcdata = (DIRCNRDATA *) mp2;
48 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETTEXTLIMIT,
49 MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
50 if (!arcdata->namecanchange) {
51 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETREADONLY,
52 MPFROM2SHORT(TRUE, 0), MPVOID);
53 WinEnableWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
54 WinShowWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
55 }
56 WinSendDlgItemMsg(hwnd, ARCH_COMMAND, EM_SETTEXTLIMIT,
57 MPFROM2SHORT(256, 0), MPVOID);
58 WinSendDlgItemMsg(hwnd, ARCH_MASKS, EM_SETTEXTLIMIT,
59 MPFROM2SHORT(256, 0), MPVOID);
60 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcdata->arcname);
61 if (arcdata->fmoving && arcdata->info->move) {
62 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->move);
63 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK,
64 MPFROM2SHORT(TRUE, 0), MPVOID);
65 }
66 else
67 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->create);
68 if (!arcdata->info->createrecurse)
69 WinEnableWindow(WinWindowFromID(hwnd, ARCH_RECURSE), FALSE);
70 if (!arcdata->info->move && !arcdata->info->movewdirs)
71 WinEnableWindow(WinWindowFromID(hwnd, ARCH_MOVE), FALSE);
72 if (!arcdata->info->createwdirs && !arcdata->info->movewdirs)
73 WinEnableWindow(WinWindowFromID(hwnd, ARCH_INCLPATH), FALSE);
74 *arcdata->command = 0;
75 PosOverOkay(hwnd);
76 break;
[2]77
[551]78 case WM_ADJUSTWINDOWPOS:
79 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
80 break;
[2]81
[551]82 case UM_SETDIR:
83 PaintRecessedWindow(WinWindowFromID(hwnd, ARCH_HELP), (HPS) 0, FALSE,
84 TRUE);
85 return 0;
[2]86
[551]87 case WM_CONTROL:
[574]88 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
[551]89 switch (SHORT1FROMMP(mp1)) {
90 case ARCH_ARCNAME:
91 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
92 WinSetDlgItemText(hwnd, ARCH_HELP,
93 GetPString(IDS_ARCDEFAULTHELPTEXT));
94 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
95 WinSetDlgItemText(hwnd, ARCH_HELP,
96 GetPString(IDS_ARCARCNAMEHELPTEXT));
97 break;
[2]98
[551]99 case ARCH_COMMAND:
100 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
101 WinSetDlgItemText(hwnd, ARCH_HELP,
102 GetPString(IDS_ARCDEFAULTHELPTEXT));
103 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
104 WinSetDlgItemText(hwnd, ARCH_HELP, GetPString(IDS_ARCCMDHELPTEXT));
105 break;
[2]106
[551]107 case ARCH_MASKS:
108 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
109 WinSetDlgItemText(hwnd, ARCH_HELP,
110 GetPString(IDS_ARCDEFAULTHELPTEXT));
111 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
112 WinSetDlgItemText(hwnd, ARCH_HELP, GetPString(IDS_ARCMASKHELPTEXT));
[2]113
[551]114 break;
[2]115
[551]116 case ARCH_INCLPATH:
117 case ARCH_RECURSE:
118 case ARCH_MOVE:
119 {
120 BOOL fRecurse = FALSE, fMove = FALSE, fInclDirs = FALSE;
121 CHAR *cmd;
[2]122
[551]123 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_QUERYCHECK,
124 MPVOID, MPVOID)) {
125 fRecurse = TRUE;
126 if (SHORT1FROMMP(mp1) == ARCH_RECURSE) {
127 if (arcdata->info->createrecurse && *arcdata->info->createrecurse) {
128 fMove = FALSE;
129 fInclDirs = FALSE;
130 WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_SETCHECK,
131 MPVOID, MPVOID);
132 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK, MPVOID, MPVOID);
133 }
134 else {
135 fRecurse = FALSE;
136 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK,
137 MPVOID, MPVOID);
138 }
139 }
140 }
141 else
142 fRecurse = FALSE;
143 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_QUERYCHECK,
144 MPVOID, MPVOID)) {
145 fMove = TRUE;
146 fRecurse = FALSE;
147 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
148 }
149 else
150 fMove = FALSE;
151 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_QUERYCHECK,
152 MPVOID, MPVOID)) {
153 fInclDirs = TRUE;
154 fRecurse = FALSE;
155 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
156 }
157 else
158 fInclDirs = FALSE;
159 cmd = NULL;
160 if (fMove) {
161 if (fInclDirs || fRecurse)
162 cmd = arcdata->info->movewdirs;
163 else
164 cmd = arcdata->info->move;
165 if (!cmd || !*cmd)
166 cmd = arcdata->info->move;
167 }
168 if (!cmd || !*cmd) {
169 if (fInclDirs) {
170 cmd = arcdata->info->createwdirs;
171 if (!cmd || !*cmd)
172 cmd = arcdata->info->createrecurse;
173 }
174 else if (fRecurse) {
175 cmd = arcdata->info->createrecurse;
176 if (!cmd || !*cmd)
177 cmd = arcdata->info->createwdirs;
178 }
179 if (!cmd || !*cmd)
180 cmd = arcdata->info->create;
181 }
182 if (cmd)
183 WinSetDlgItemText(hwnd, ARCH_COMMAND, cmd);
[2]184 }
[551]185 break;
186 }
187 return 0;
188
189 case WM_COMMAND:
[574]190 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
[551]191 if (!arcdata) {
192 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]193 return 0;
[551]194 }
195 switch (SHORT1FROMMP(mp1)) {
196 case DID_CANCEL:
197 WinDismissDlg(hwnd, 0);
198 break;
199 case DID_OK:
200 {
201 CHAR s[CCHMAXPATH + 1];
[2]202
[551]203 *s = 0;
204 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
205 bstrip(s);
206 if (*s) {
207 if (DosQueryPathInfo(s,
208 FIL_QUERYFULLNAME,
209 arcdata->arcname, CCHMAXPATH))
210 strcpy(arcdata->arcname, s);
211 *s = 0;
212 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
213 if (*s) {
214 strcpy(arcdata->command, s);
215 *s = 0;
216 WinQueryDlgItemText(hwnd, ARCH_MASKS, 256, s);
217 *arcdata->mask.szMask = 0;
218 strcpy(arcdata->mask.szMask, s);
219 WinDismissDlg(hwnd, 1);
220 break;
221 }
222 }
[2]223 }
[551]224 DosBeep(50, 100);
225 break;
[2]226
[551]227 case IDM_HELP:
228 if (hwndHelp)
229 WinSendMsg(hwndHelp,
230 HM_DISPLAY_HELP,
231 MPFROM2SHORT(HELP_ARCHIVE, 0), MPFROMSHORT(HM_RESOURCEID));
232 break;
[2]233
[551]234 case ARCH_FIND:
235 if (arcdata->namecanchange) {
[2]236
[551]237 CHAR arcname[CCHMAXPATH], s[CCHMAXPATH], *p;
[2]238
[551]239 *s = 0;
240 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
241 bstrip(s);
242 if (DosQueryPathInfo(s, FIL_QUERYFULLNAME, arcname, CCHMAXPATH))
243 strcpy(arcname, s);
244 p = strrchr(arcname, '\\');
245 if (p) {
246 p++;
247 p = strrchr(arcname, '.');
248 }
249 if (!p && arcdata->info->ext && *arcdata->info->ext) {
250 strcat(arcname, "*.");
251 strcat(arcname, arcdata->info->ext);
252 }
253 if (export_filename(hwnd, arcname, FALSE))
254 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcname);
255 }
256 break;
[2]257
[551]258 case ARCH_SEE:
259 {
260 CHAR s[1001], *p;
[2]261
[551]262 *s = 0;
263 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
264 bstrip(s);
265 if (*s) {
266 p = strchr(s, ' ');
267 if (p)
268 *p = 0;
269 ExecOnList(hwnd, s, WINDOWED | SEPARATEKEEP | MAXIMIZED | PROMPT,
[888]270 NULL, NULL, GetPString(IDS_ARCEXECHELPTEXT),
271 pszSrcFile, __LINE__);
[551]272 }
273 else
274 DosBeep(50, 100);
[2]275 }
[551]276 break;
277 }
278 return 0;
[2]279
[551]280 case WM_CLOSE:
281 break;
[2]282 }
[551]283 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]284}
[793]285
286#pragma alloc_text(FMARCHIVE,ArchiveDlgProc)
Note: See TracBrowser for help on using the repository browser.