source: trunk/dll/archive.c@ 574

Last change on this file since 574 was 574, checked in by Gregg Young, 18 years ago

Use QWL_USER; Replace doesn't move the command and Okay on cmd dialog removed error on unchanged command

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