source: trunk/dll/archive.c@ 1220

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

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