source: trunk/dll/archive.c@ 1179

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

Ticket 187: Draft 2: Move remaining function declarations

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