| 1 |  | 
|---|
| 2 | /*********************************************************************** | 
|---|
| 3 |  | 
|---|
| 4 | $Id: objcnr.c 1335 2008-12-12 23:49:02Z stevenhl $ | 
|---|
| 5 |  | 
|---|
| 6 | Object containers | 
|---|
| 7 |  | 
|---|
| 8 | Copyright (c) 1993-98 M. Kimes | 
|---|
| 9 | Copyright (c) 2005, 2008 Steven H. Levine | 
|---|
| 10 |  | 
|---|
| 11 | 24 May 05 SHL Rework for CNRITEM.szSubject | 
|---|
| 12 | 13 Jul 06 SHL Use Runtime_Error | 
|---|
| 13 | 01 Sep 06 SHL Do not complain for normal cancel | 
|---|
| 14 | 19 Oct 06 SHL Correct . and .. detect | 
|---|
| 15 | 03 Nov 06 SHL Renames | 
|---|
| 16 | 22 Mar 07 GKY Use QWL_USER | 
|---|
| 17 | 01 Aug 07 SHL Rework to sync with CNRITEM mods | 
|---|
| 18 | 03 Aug 07 GKY Enlarged and made setable everywhere Findbuf (speed file loading) | 
|---|
| 19 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148) | 
|---|
| 20 | 13 Aug 07 SHL Avoid realloc - not needed; sanitize code | 
|---|
| 21 | 13 Aug 07 SHL Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| 22 | 14 Aug 07 SHL Revert ProcessDir DosSleep to 0 | 
|---|
| 23 | 29 Feb 08 GKY Use xfree where appropriate | 
|---|
| 24 | 10 Dec 08 SHL Integrate exception handler support | 
|---|
| 25 |  | 
|---|
| 26 | ***********************************************************************/ | 
|---|
| 27 |  | 
|---|
| 28 | #include <stdlib.h> | 
|---|
| 29 | #include <string.h> | 
|---|
| 30 | #include <ctype.h> | 
|---|
| 31 | // #include <process.h>                 // _beginthread | 
|---|
| 32 |  | 
|---|
| 33 | #define INCL_DOS | 
|---|
| 34 | #define INCL_WIN | 
|---|
| 35 | #define INCL_DOSERRORS | 
|---|
| 36 | #define INCL_LONGLONG | 
|---|
| 37 |  | 
|---|
| 38 | #include "fm3dll.h" | 
|---|
| 39 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| 40 | #include "draglist.h"                   // Data declaration(s) | 
|---|
| 41 | #include "info.h"                       // Data declaration(s) | 
|---|
| 42 | #include "init.h"                       // Data declaration(s) | 
|---|
| 43 | #include "notebook.h"                   // Data declaration(s) | 
|---|
| 44 | #include "newview.h"                    // Data declarations | 
|---|
| 45 | #include "fm3dlg.h" | 
|---|
| 46 | #include "fm3str.h" | 
|---|
| 47 | #include "errutil.h"                    // Dos_Error... | 
|---|
| 48 | #include "strutil.h"                    // GetPString | 
|---|
| 49 | #include "objcnr.h" | 
|---|
| 50 | #include "notify.h"                     // Notify | 
|---|
| 51 | #include "wrappers.h"                   // xDosFindNext | 
|---|
| 52 | #include "select.h"                     // ExpandAll | 
|---|
| 53 | #include "valid.h"                      // IsRoot | 
|---|
| 54 | #include "misc.h"                       // PostMsg | 
|---|
| 55 | #include "fortify.h" | 
|---|
| 56 | #include "excputil.h"                   // xbeginthread | 
|---|
| 57 |  | 
|---|
| 58 | typedef struct | 
|---|
| 59 | { | 
|---|
| 60 | CHAR *filename; | 
|---|
| 61 | HWND hwndCnr; | 
|---|
| 62 | CHAR *stopflag; | 
|---|
| 63 | } | 
|---|
| 64 | DIRSIZE; | 
|---|
| 65 |  | 
|---|
| 66 | typedef struct | 
|---|
| 67 | { | 
|---|
| 68 | CHAR *dirname; | 
|---|
| 69 | CHAR stopflag; | 
|---|
| 70 | BOOL dying; | 
|---|
| 71 | BOOL working; | 
|---|
| 72 | } | 
|---|
| 73 | TEMP; | 
|---|
| 74 |  | 
|---|
| 75 | #pragma data_seg(DATA1) | 
|---|
| 76 |  | 
|---|
| 77 | static PSZ pszSrcFile = __FILE__; | 
|---|
| 78 |  | 
|---|
| 79 | static HWND objcnrwnd; | 
|---|
| 80 |  | 
|---|
| 81 | static VOID ProcessDir(HWND hwndCnr, | 
|---|
| 82 | CHAR *filename, | 
|---|
| 83 | PCNRITEM pciParent, | 
|---|
| 84 | CHAR *stopflag) | 
|---|
| 85 | { | 
|---|
| 86 | CHAR maskstr[CCHMAXPATH], *endpath, *p; | 
|---|
| 87 | ULONG ulFindCnt, ulFindMax; | 
|---|
| 88 | ULONG ulBufBytes; | 
|---|
| 89 | HDIR hdir; | 
|---|
| 90 | PFILEFINDBUF3L pffbArray; | 
|---|
| 91 | APIRET rc; | 
|---|
| 92 | RECORDINSERT ri; | 
|---|
| 93 | PCNRITEM pciP; | 
|---|
| 94 | HPOINTER hptr; | 
|---|
| 95 |  | 
|---|
| 96 | ulBufBytes = sizeof(FILEFINDBUF3L) * FilesToGet; | 
|---|
| 97 | pffbArray = xmalloc(ulBufBytes, pszSrcFile, __LINE__); | 
|---|
| 98 | if (!pffbArray) | 
|---|
| 99 | return;                             // Error already reported | 
|---|
| 100 | strcpy(maskstr, filename); | 
|---|
| 101 | if (maskstr[strlen(maskstr) - 1] != '\\') | 
|---|
| 102 | strcat(maskstr, "\\"); | 
|---|
| 103 | endpath = &maskstr[strlen(maskstr)]; | 
|---|
| 104 | strcat(maskstr, "*"); | 
|---|
| 105 | hdir = HDIR_CREATE; | 
|---|
| 106 | ulFindCnt = 1; | 
|---|
| 107 | rc = xDosFindFirst(filename, &hdir, | 
|---|
| 108 | FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | | 
|---|
| 109 | FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, | 
|---|
| 110 | pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARDL); | 
|---|
| 111 | if (!rc) | 
|---|
| 112 | DosFindClose(hdir); | 
|---|
| 113 | // work around furshluginer FAT root bug | 
|---|
| 114 | else if (IsRoot(filename)) | 
|---|
| 115 | rc = 0; | 
|---|
| 116 |  | 
|---|
| 117 | if ((!rc && (pffbArray->attrFile & FILE_DIRECTORY))) { | 
|---|
| 118 | pciP = WinSendMsg(hwndCnr, | 
|---|
| 119 | CM_ALLOCRECORD, | 
|---|
| 120 | MPFROMLONG(EXTRA_RECORD_BYTES), | 
|---|
| 121 | MPFROMLONG(1)); | 
|---|
| 122 | if (!pciP) { | 
|---|
| 123 | Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__, "CM_ALLOCRECORD"); | 
|---|
| 124 | free(pffbArray); | 
|---|
| 125 | return; | 
|---|
| 126 | } | 
|---|
| 127 | pciP->pszFileName = xstrdup(filename, pszSrcFile, __LINE__); | 
|---|
| 128 | pciP->pszDispAttr = NullStr; | 
|---|
| 129 | pciP->pszSubject = NullStr; | 
|---|
| 130 | pciP->pszLongName = NullStr; | 
|---|
| 131 | if (strlen(filename) < 4) | 
|---|
| 132 | pciP->pszDisplayName = pciP->pszFileName; | 
|---|
| 133 | else { | 
|---|
| 134 | p = strrchr(pciP->pszFileName, '\\'); | 
|---|
| 135 | if (!p) | 
|---|
| 136 | pciP->pszDisplayName = pciP->pszFileName; | 
|---|
| 137 | else if (*(p + 1)) | 
|---|
| 138 | p++; | 
|---|
| 139 | pciP->pszDisplayName = p; | 
|---|
| 140 | } | 
|---|
| 141 | pciP->rc.pszIcon = pciP->pszDisplayName; | 
|---|
| 142 | if (fForceUpper) | 
|---|
| 143 | strupr(pciP->pszFileName); | 
|---|
| 144 | else if (fForceLower) | 
|---|
| 145 | strlwr(pciP->pszFileName); | 
|---|
| 146 | pciP->rc.flRecordAttr |= CRA_RECORDREADONLY; | 
|---|
| 147 | } | 
|---|
| 148 | else { | 
|---|
| 149 | free(pffbArray); | 
|---|
| 150 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 151 | GetPString(IDS_CANTFINDDIRTEXT), filename); | 
|---|
| 152 | return; | 
|---|
| 153 | } | 
|---|
| 154 |  | 
|---|
| 155 | hptr = WinLoadFileIcon(pciP->pszFileName, FALSE); | 
|---|
| 156 | if (hptr) | 
|---|
| 157 | pciP->rc.hptrIcon = hptr; | 
|---|
| 158 |  | 
|---|
| 159 | if (!pciP->rc.hptrIcon || pciP->rc.hptrIcon == hptrFile)      /* OS/2 bug bug bug bug */ | 
|---|
| 160 | pciP->rc.hptrIcon = hptrDir; | 
|---|
| 161 |  | 
|---|
| 162 | memset(&ri, 0, sizeof(RECORDINSERT)); | 
|---|
| 163 | ri.cb = sizeof(RECORDINSERT); | 
|---|
| 164 | ri.pRecordOrder = (PRECORDCORE) CMA_END; | 
|---|
| 165 | ri.pRecordParent = (PRECORDCORE) pciParent; | 
|---|
| 166 | ri.zOrder = (USHORT) CMA_TOP; | 
|---|
| 167 | ri.cRecordsInsert = 1; | 
|---|
| 168 | ri.fInvalidateRecord = TRUE; | 
|---|
| 169 | if (!WinSendMsg(hwndCnr, CM_INSERTRECORD, MPFROMP(pciP), MPFROMP(&ri))) { | 
|---|
| 170 | free(pffbArray); | 
|---|
| 171 | return; | 
|---|
| 172 | } | 
|---|
| 173 | hdir = HDIR_CREATE; | 
|---|
| 174 | if (!isalpha(*maskstr) || maskstr[1] != ':' || maskstr[2] != '\\' || | 
|---|
| 175 | ((driveflags[toupper(*maskstr) - 'A'] & DRIVE_REMOTE) && fRemoteBug)) | 
|---|
| 176 | ulFindMax = 1; | 
|---|
| 177 | else | 
|---|
| 178 | ulFindMax = FilesToGet; | 
|---|
| 179 | ulFindCnt = ulFindMax; | 
|---|
| 180 | rc = xDosFindFirst(maskstr, &hdir, | 
|---|
| 181 | FILE_NORMAL | FILE_READONLY | FILE_ARCHIVED | | 
|---|
| 182 | FILE_SYSTEM | FILE_HIDDEN | MUST_HAVE_DIRECTORY, | 
|---|
| 183 | pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARDL); | 
|---|
| 184 | if (!rc) { | 
|---|
| 185 | PFILEFINDBUF3L pffbFile; | 
|---|
| 186 | ULONG x; | 
|---|
| 187 |  | 
|---|
| 188 | while (!rc) { | 
|---|
| 189 | pffbFile = pffbArray; | 
|---|
| 190 | for (x = 0; x < ulFindCnt; x++) { | 
|---|
| 191 | if (*stopflag) | 
|---|
| 192 | break; | 
|---|
| 193 | if ((pffbFile->attrFile & FILE_DIRECTORY) && | 
|---|
| 194 | // Skip . and .. | 
|---|
| 195 | (pffbFile->achName[0] != '.' || | 
|---|
| 196 | (pffbFile->achName[1] && | 
|---|
| 197 | (pffbFile->achName[1] != '.' || pffbFile->achName[2])))) { | 
|---|
| 198 | strcpy(endpath, pffbFile->achName); | 
|---|
| 199 | ProcessDir(hwndCnr, maskstr, pciP, stopflag); | 
|---|
| 200 | } | 
|---|
| 201 | if (!pffbFile->oNextEntryOffset) | 
|---|
| 202 | break; | 
|---|
| 203 | pffbFile = (PFILEFINDBUF3L)((PBYTE)pffbFile + pffbFile->oNextEntryOffset); | 
|---|
| 204 | } // for | 
|---|
| 205 | DosSleep(0);                      // Let's others at same priority get some work done | 
|---|
| 206 | if (*stopflag) | 
|---|
| 207 | break; | 
|---|
| 208 | ulFindCnt = ulFindMax; | 
|---|
| 209 | rc = xDosFindNext(hdir, pffbArray, ulBufBytes, &ulFindCnt, FIL_STANDARDL); | 
|---|
| 210 | } // while | 
|---|
| 211 | DosFindClose(hdir); | 
|---|
| 212 | } | 
|---|
| 213 |  | 
|---|
| 214 | if (rc && rc != ERROR_NO_MORE_FILES) { | 
|---|
| 215 | Dos_Error(MB_ENTER, rc, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| 216 | GetPString(IDS_CANTFINDDIRTEXT), filename); | 
|---|
| 217 | } | 
|---|
| 218 |  | 
|---|
| 219 | free(pffbArray); | 
|---|
| 220 | WinSendMsg(hwndCnr, CM_INVALIDATERECORD, MPFROMP(&pciP), | 
|---|
| 221 | MPFROM2SHORT(1, 0)); | 
|---|
| 222 | } | 
|---|
| 223 |  | 
|---|
| 224 | static VOID FillCnrsThread(VOID * args) | 
|---|
| 225 | { | 
|---|
| 226 | HAB hab; | 
|---|
| 227 | HMQ hmq; | 
|---|
| 228 | DIRSIZE *dirsize = (DIRSIZE *)args; | 
|---|
| 229 |  | 
|---|
| 230 | # ifdef FORTIFY | 
|---|
| 231 | Fortify_EnterScope(); | 
|---|
| 232 | #  endif | 
|---|
| 233 | if (!dirsize) { | 
|---|
| 234 | Runtime_Error(pszSrcFile, __LINE__, "no data"); | 
|---|
| 235 | return; | 
|---|
| 236 | } | 
|---|
| 237 |  | 
|---|
| 238 | DosError(FERR_DISABLEHARDERR); | 
|---|
| 239 |  | 
|---|
| 240 | hab = WinInitialize(0); | 
|---|
| 241 | if (hab) { | 
|---|
| 242 | hmq = WinCreateMsgQueue(hab, 0); | 
|---|
| 243 | if (hmq) { | 
|---|
| 244 | WinCancelShutdown(hmq, TRUE); | 
|---|
| 245 | ProcessDir(dirsize->hwndCnr, dirsize->filename, (PCNRITEM) NULL, | 
|---|
| 246 | dirsize->stopflag); | 
|---|
| 247 | DosPostEventSem(CompactSem); | 
|---|
| 248 | WinDestroyMsgQueue(hmq); | 
|---|
| 249 | } | 
|---|
| 250 | WinTerminate(hab); | 
|---|
| 251 | } | 
|---|
| 252 | PostMsg(WinQueryWindow(dirsize->hwndCnr, QW_PARENT), UM_CONTAINER_FILLED, | 
|---|
| 253 | MPVOID, MPVOID); | 
|---|
| 254 | free(dirsize); | 
|---|
| 255 | # ifdef FORTIFY | 
|---|
| 256 | Fortify_LeaveScope(); | 
|---|
| 257 | #  endif | 
|---|
| 258 | } | 
|---|
| 259 |  | 
|---|
| 260 | MRESULT EXPENTRY ObjCnrDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
| 261 | { | 
|---|
| 262 | TEMP *data; | 
|---|
| 263 |  | 
|---|
| 264 | switch (msg) { | 
|---|
| 265 | case WM_INITDLG: | 
|---|
| 266 | if (objcnrwnd) { | 
|---|
| 267 | Runtime_Error(pszSrcFile, __LINE__, "objcnrwnd set"); | 
|---|
| 268 | WinSetWindowPos(objcnrwnd, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 269 | SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER); | 
|---|
| 270 | WinDismissDlg(hwnd, 0); | 
|---|
| 271 | break; | 
|---|
| 272 | } | 
|---|
| 273 | if (!mp2) { | 
|---|
| 274 | Runtime_Error(pszSrcFile, __LINE__, "mp2 NULL"); | 
|---|
| 275 | WinDismissDlg(hwnd, 0); | 
|---|
| 276 | break; | 
|---|
| 277 | } | 
|---|
| 278 | objcnrwnd = hwnd; | 
|---|
| 279 | data = xmallocz(sizeof(TEMP), pszSrcFile, __LINE__); | 
|---|
| 280 | if (!data) { | 
|---|
| 281 | WinDismissDlg(hwnd, 0); | 
|---|
| 282 | break; | 
|---|
| 283 | } | 
|---|
| 284 | data->dirname = (CHAR *)mp2; | 
|---|
| 285 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) data); | 
|---|
| 286 | if (*data->dirname) | 
|---|
| 287 | WinSetDlgItemText(hwnd, OBJCNR_DIR, data->dirname); | 
|---|
| 288 | { | 
|---|
| 289 | DIRSIZE *dirsize; | 
|---|
| 290 | #     ifdef FORTIFY | 
|---|
| 291 | Fortify_EnterScope(); | 
|---|
| 292 | #      endif | 
|---|
| 293 | dirsize = xmalloc(sizeof(DIRSIZE), pszSrcFile, __LINE__); | 
|---|
| 294 | if (!dirsize) { | 
|---|
| 295 | WinDismissDlg(hwnd, 0); | 
|---|
| 296 | break; | 
|---|
| 297 | } | 
|---|
| 298 | dirsize->stopflag = (CHAR *)&data->stopflag; | 
|---|
| 299 | dirsize->filename = data->dirname; | 
|---|
| 300 | dirsize->hwndCnr = WinWindowFromID(hwnd, OBJCNR_CNR); | 
|---|
| 301 | if (xbeginthread(FillCnrsThread, | 
|---|
| 302 | 65536 * 8, | 
|---|
| 303 | dirsize, | 
|---|
| 304 | pszSrcFile, | 
|---|
| 305 | __LINE__) == -1) | 
|---|
| 306 | { | 
|---|
| 307 | free(dirsize); | 
|---|
| 308 | #       ifdef FORTIFY | 
|---|
| 309 | Fortify_LeaveScope(); | 
|---|
| 310 | #        endif | 
|---|
| 311 | WinDismissDlg(hwnd, 0); | 
|---|
| 312 | break; | 
|---|
| 313 | } | 
|---|
| 314 | else | 
|---|
| 315 | data->working = TRUE; | 
|---|
| 316 | } | 
|---|
| 317 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID); | 
|---|
| 318 | break; | 
|---|
| 319 |  | 
|---|
| 320 | case UM_SETUP: | 
|---|
| 321 | // WinEnableWindowUpdate(WinWindowFromID(hwnd,OBJCNR_CNR),FALSE); | 
|---|
| 322 | { | 
|---|
| 323 | CNRINFO cnri; | 
|---|
| 324 |  | 
|---|
| 325 | memset(&cnri, 0, sizeof(CNRINFO)); | 
|---|
| 326 | cnri.cb = sizeof(CNRINFO); | 
|---|
| 327 | WinSendDlgItemMsg(hwnd, OBJCNR_CNR, CM_QUERYCNRINFO, | 
|---|
| 328 | MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO))); | 
|---|
| 329 | cnri.cyLineSpacing = 0; | 
|---|
| 330 | cnri.cxTreeIndent = 12L; | 
|---|
| 331 | cnri.pszCnrTitle = GetPString(IDS_WORKINGTEXT); | 
|---|
| 332 | cnri.flWindowAttr = CV_TREE | CV_FLOW | | 
|---|
| 333 | CA_CONTAINERTITLE | CA_TITLESEPARATOR | CA_TREELINE; | 
|---|
| 334 | if (WinQueryWindowUShort(hwnd, QWS_ID) == QTREE_FRAME) | 
|---|
| 335 | cnri.flWindowAttr |= CV_MINI; | 
|---|
| 336 | WinSendDlgItemMsg(hwnd, OBJCNR_CNR, CM_SETCNRINFO, MPFROMP(&cnri), | 
|---|
| 337 | MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING | | 
|---|
| 338 | CMA_CXTREEINDENT)); | 
|---|
| 339 | } | 
|---|
| 340 | return 0; | 
|---|
| 341 |  | 
|---|
| 342 | case UM_CONTAINER_FILLED: | 
|---|
| 343 | WinSetDlgItemText(hwnd, OBJCNR_NOTE, NullStr); | 
|---|
| 344 | //      WinEnableWindowUpdate(WinWindowFromID(hwnd,OBJCNR_CNR),TRUE); | 
|---|
| 345 | WinSendDlgItemMsg(hwnd, OBJCNR_CNR, CM_INVALIDATERECORD, MPVOID, | 
|---|
| 346 | MPFROM2SHORT(0, CMA_ERASE | CMA_INVALIDATE)); | 
|---|
| 347 | data = INSTDATA(hwnd); | 
|---|
| 348 | if (data) { | 
|---|
| 349 | data->working = FALSE; | 
|---|
| 350 | if (data->dying) | 
|---|
| 351 | WinDismissDlg(hwnd, 0); | 
|---|
| 352 | { | 
|---|
| 353 | PCNRITEM pci; | 
|---|
| 354 | USHORT id; | 
|---|
| 355 |  | 
|---|
| 356 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 357 | pci = (PCNRITEM) WinSendDlgItemMsg(hwnd, OBJCNR_CNR, | 
|---|
| 358 | CM_QUERYRECORD, | 
|---|
| 359 | MPVOID, | 
|---|
| 360 | MPFROM2SHORT(CMA_FIRST, | 
|---|
| 361 | CMA_ITEMORDER)); | 
|---|
| 362 | if (pci && (INT) pci != -1) { | 
|---|
| 363 | ExpandAll(WinWindowFromID(hwnd, OBJCNR_CNR), TRUE, pci); | 
|---|
| 364 | if (id == QTREE_FRAME) | 
|---|
| 365 | pci = (PCNRITEM) WinSendDlgItemMsg(hwnd, OBJCNR_CNR, | 
|---|
| 366 | CM_QUERYRECORD, | 
|---|
| 367 | MPFROMP(pci), | 
|---|
| 368 | MPFROM2SHORT(CMA_FIRSTCHILD, | 
|---|
| 369 | CMA_ITEMORDER)); | 
|---|
| 370 | } | 
|---|
| 371 | if ((!pci || (INT) pci == -1) && id == QTREE_FRAME) { | 
|---|
| 372 | Notify(GetPString(IDS_NODIRSUNDERTEXT)); | 
|---|
| 373 | WinDismissDlg(hwnd, 0); | 
|---|
| 374 | break; | 
|---|
| 375 | } | 
|---|
| 376 | } | 
|---|
| 377 | } | 
|---|
| 378 | return 0; | 
|---|
| 379 |  | 
|---|
| 380 | case WM_CONTROL: | 
|---|
| 381 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 382 | case OBJCNR_CNR: | 
|---|
| 383 | if (SHORT2FROMMP(mp1) == CN_ENTER) { | 
|---|
| 384 |  | 
|---|
| 385 | PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord; | 
|---|
| 386 |  | 
|---|
| 387 | if (pci && (INT) pci != -1) | 
|---|
| 388 | WinSendDlgItemMsg(hwnd, DID_OK, BM_CLICK, MPVOID, MPVOID); | 
|---|
| 389 | } | 
|---|
| 390 | break; | 
|---|
| 391 | } | 
|---|
| 392 | return 0; | 
|---|
| 393 |  | 
|---|
| 394 | case WM_COMMAND: | 
|---|
| 395 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| 396 | case IDM_HELP: | 
|---|
| 397 | if (hwndHelp) { | 
|---|
| 398 |  | 
|---|
| 399 | USHORT id; | 
|---|
| 400 |  | 
|---|
| 401 | id = WinQueryWindowUShort(hwnd, QWS_ID); | 
|---|
| 402 |  | 
|---|
| 403 | if (id == QTREE_FRAME) | 
|---|
| 404 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 405 | MPFROM2SHORT(HELP_QUICKTREE, 0), | 
|---|
| 406 | MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 407 | else | 
|---|
| 408 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, | 
|---|
| 409 | MPFROM2SHORT(HELP_OBJECTPATH, 0), | 
|---|
| 410 | MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| 411 | } | 
|---|
| 412 | break; | 
|---|
| 413 |  | 
|---|
| 414 | case OBJCNR_DESKTOP: | 
|---|
| 415 | case DID_OK: | 
|---|
| 416 | data = INSTDATA(hwnd); | 
|---|
| 417 | if (data) { | 
|---|
| 418 |  | 
|---|
| 419 | PCNRITEM pci; | 
|---|
| 420 |  | 
|---|
| 421 | if (data->working) { | 
|---|
| 422 | Runtime_Error(pszSrcFile, __LINE__, "working unexpected"); | 
|---|
| 423 | break; | 
|---|
| 424 | } | 
|---|
| 425 | if (SHORT1FROMMP(mp1) == OBJCNR_DESKTOP) { | 
|---|
| 426 | WinDismissDlg(hwnd, 2); | 
|---|
| 427 | break; | 
|---|
| 428 | } | 
|---|
| 429 | pci = (PCNRITEM) WinSendDlgItemMsg(hwnd, OBJCNR_CNR, | 
|---|
| 430 | CM_QUERYRECORDEMPHASIS, | 
|---|
| 431 | MPFROMLONG(CMA_FIRST), | 
|---|
| 432 | MPFROMSHORT(CRA_CURSORED)); | 
|---|
| 433 | if (pci && (INT) pci != -1) | 
|---|
| 434 | strcpy(data->dirname, pci->pszFileName); | 
|---|
| 435 | WinDismissDlg(hwnd, 1); | 
|---|
| 436 | } | 
|---|
| 437 | break; | 
|---|
| 438 |  | 
|---|
| 439 | case DID_CANCEL: | 
|---|
| 440 | data = INSTDATA(hwnd); | 
|---|
| 441 | if (data) { | 
|---|
| 442 | if (data->working) { | 
|---|
| 443 | data->dying = (CHAR)TRUE; | 
|---|
| 444 | data->stopflag = (CHAR)0xff; | 
|---|
| 445 | break; | 
|---|
| 446 | } | 
|---|
| 447 | WinDismissDlg(hwnd, 0); | 
|---|
| 448 | } | 
|---|
| 449 | break; | 
|---|
| 450 | } | 
|---|
| 451 | return 0; | 
|---|
| 452 |  | 
|---|
| 453 | case WM_DESTROY: | 
|---|
| 454 | objcnrwnd = (HWND) 0; | 
|---|
| 455 | data = INSTDATA(hwnd); | 
|---|
| 456 | xfree(data, pszSrcFile, __LINE__); | 
|---|
| 457 | break; | 
|---|
| 458 | } | 
|---|
| 459 | return WinDefDlgProc(hwnd, msg, mp1, mp2); | 
|---|
| 460 | } | 
|---|
| 461 |  | 
|---|
| 462 | #pragma alloc_text(OBJCNR,ProcessDir,FillCnrsThread,ObjCnrDlgProc) | 
|---|