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
RevLine 
[123]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
[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
[123]15
16***********************************************************************/
17
[2]18#define INCL_WIN
19#define INCL_DOS
[318]20#include <os2.h>
[2]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>
[318]28
[2]29#include "fm3dll.h"
30#include "fm3dlg.h"
31#include "fm3str.h"
32
[342]33static PSZ pszSrcFile = __FILE__;
34
[2]35#pragma alloc_text(FMARCHIVE,ArchiveDlgProc)
36
[551]37MRESULT EXPENTRY ArchiveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[123]38{
[551]39 DIRCNRDATA *arcdata = NULL;
[2]40
[551]41 switch (msg) {
42 case WM_INITDLG:
[574]43 WinSetWindowPtr(hwnd, QWL_USER, mp2);
[551]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;
[2]74
[551]75 case WM_ADJUSTWINDOWPOS:
76 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
77 break;
[2]78
[551]79 case UM_SETDIR:
80 PaintRecessedWindow(WinWindowFromID(hwnd, ARCH_HELP), (HPS) 0, FALSE,
81 TRUE);
82 return 0;
[2]83
[551]84 case WM_CONTROL:
[574]85 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
[551]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;
[2]95
[551]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;
[2]103
[551]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));
[2]110
[551]111 break;
[2]112
[551]113 case ARCH_INCLPATH:
114 case ARCH_RECURSE:
115 case ARCH_MOVE:
116 {
117 BOOL fRecurse = FALSE, fMove = FALSE, fInclDirs = FALSE;
118 CHAR *cmd;
[2]119
[551]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);
[2]181 }
[551]182 break;
183 }
184 return 0;
185
186 case WM_COMMAND:
[574]187 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
[551]188 if (!arcdata) {
189 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[2]190 return 0;
[551]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];
[2]199
[551]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 }
[2]220 }
[551]221 DosBeep(50, 100);
222 break;
[2]223
[551]224 case IDM_HELP:
225 if (hwndHelp)
226 WinSendMsg(hwndHelp,
227 HM_DISPLAY_HELP,
228 MPFROM2SHORT(HELP_ARCHIVE, 0), MPFROMSHORT(HM_RESOURCEID));
229 break;
[2]230
[551]231 case ARCH_FIND:
232 if (arcdata->namecanchange) {
[2]233
[551]234 CHAR arcname[CCHMAXPATH], s[CCHMAXPATH], *p;
[2]235
[551]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;
[2]254
[551]255 case ARCH_SEE:
256 {
257 CHAR s[1001], *p;
[2]258
[551]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);
[2]271 }
[551]272 break;
273 }
274 return 0;
[2]275
[551]276 case WM_CLOSE:
277 break;
[2]278 }
[551]279 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]280}
Note: See TracBrowser for help on using the repository browser.