| [793] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: findrec.c 1550 2010-11-03 02:50:42Z gyoung $ | 
|---|
|  | 5 |  | 
|---|
|  | 6 | Copyright (c) 1993-98 M. Kimes | 
|---|
| [1347] | 7 | Copyright (c) 2003, 2008 Steven H.Levine | 
|---|
| [793] | 8 |  | 
|---|
|  | 9 | Find records | 
|---|
|  | 10 |  | 
|---|
|  | 11 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat | 
|---|
| [1361] | 12 | 28 Dec 08 GKY Containers will only scroll to the right if needed to show end of selected | 
|---|
|  | 13 | item and will scroll left to eliminate space after a selected item. Ticket 204 | 
|---|
| [793] | 14 |  | 
|---|
|  | 15 | ***********************************************************************/ | 
|---|
|  | 16 |  | 
|---|
| [907] | 17 | #include <string.h> | 
|---|
| [1549] | 18 | #include <stdlib.h> | 
|---|
| [2] | 19 |  | 
|---|
| [907] | 20 | #define INCL_LONGLONG                   // dircnrs.h | 
|---|
|  | 21 |  | 
|---|
| [2] | 22 | #include "fm3dll.h" | 
|---|
| [1160] | 23 | #include "findrec.h" | 
|---|
| [1549] | 24 | #include "errutil.h"                    // Dos_Error... | 
|---|
| [2] | 25 |  | 
|---|
| [1549] | 26 | //static PSZ pszSrcFile = __FILE__; | 
|---|
|  | 27 |  | 
|---|
| [1434] | 28 | PCNRITEM FindCnrRecord(HWND hwndCnr, CHAR *filename, PCNRITEM pciParent, | 
|---|
| [551] | 29 | BOOL partial, BOOL partmatch, BOOL noenv) | 
|---|
|  | 30 | { | 
|---|
|  | 31 | SEARCHSTRING srch; | 
|---|
|  | 32 | PCNRITEM pci; | 
|---|
|  | 33 | register CHAR *file, *p; | 
|---|
| [2] | 34 |  | 
|---|
| [551] | 35 | if (partial) { | 
|---|
|  | 36 | if (strlen(filename) > 3) { | 
|---|
|  | 37 | file = strrchr(filename, '\\'); | 
|---|
|  | 38 | if (!file) { | 
|---|
|  | 39 | file = strrchr(filename, ':'); | 
|---|
|  | 40 | if (file) | 
|---|
|  | 41 | file++; | 
|---|
|  | 42 | else | 
|---|
|  | 43 | file = filename; | 
|---|
| [2] | 44 | } | 
|---|
|  | 45 | else | 
|---|
| [551] | 46 | file++; | 
|---|
| [2] | 47 | } | 
|---|
|  | 48 | else | 
|---|
|  | 49 | file = filename; | 
|---|
|  | 50 | } | 
|---|
|  | 51 | else | 
|---|
|  | 52 | file = filename; | 
|---|
| [551] | 53 | memset(&srch, 0, sizeof(SEARCHSTRING)); | 
|---|
|  | 54 | srch.cb = (ULONG) sizeof(SEARCHSTRING); | 
|---|
|  | 55 | srch.pszSearch = (PSZ) file; | 
|---|
| [2] | 56 | srch.fsPrefix = FALSE; | 
|---|
|  | 57 | srch.fsCaseSensitive = FALSE; | 
|---|
| [551] | 58 | srch.usView = CV_TREE;                /* | CV_EXACTMATCH; */ | 
|---|
|  | 59 | if (!pciParent) | 
|---|
|  | 60 | pciParent = (PCNRITEM) CMA_FIRST; | 
|---|
| [2] | 61 | pci = WinSendMsg(hwndCnr, | 
|---|
| [551] | 62 | CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pciParent)); | 
|---|
|  | 63 | while (pci && (INT) pci != -1) { | 
|---|
|  | 64 | if (!noenv || (pci->flags & (RECFLAGS_ENV | RECFLAGS_UNDERENV)) == 0) { | 
|---|
|  | 65 | if (!partmatch) {                 /* full name must match full name */ | 
|---|
| [730] | 66 | if (!stricmp(pci->pszFileName, filename)) | 
|---|
| [551] | 67 | return pci;                   /* success */ | 
|---|
| [2] | 68 | } | 
|---|
| [551] | 69 | else {                            /* only root name must match */ | 
|---|
| [730] | 70 | if (strlen(pci->pszFileName) > 3) { | 
|---|
|  | 71 | p = strrchr(pci->pszFileName, '\\'); | 
|---|
| [551] | 72 | if (!p) { | 
|---|
| [730] | 73 | p = strrchr(pci->pszFileName, ':'); | 
|---|
| [551] | 74 | if (p) | 
|---|
|  | 75 | p++; | 
|---|
|  | 76 | else | 
|---|
| [730] | 77 | p = pci->pszFileName; | 
|---|
| [551] | 78 | } | 
|---|
|  | 79 | else | 
|---|
|  | 80 | p++; | 
|---|
|  | 81 | } | 
|---|
|  | 82 | else | 
|---|
| [730] | 83 | p = pci->pszFileName; | 
|---|
| [551] | 84 | if (!stricmp(p, file)) | 
|---|
|  | 85 | return pci;                   /* success */ | 
|---|
| [2] | 86 | } | 
|---|
|  | 87 | } | 
|---|
| [551] | 88 | pci = WinSendMsg(hwndCnr, CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pci)); | 
|---|
| [2] | 89 | } | 
|---|
| [689] | 90 |  | 
|---|
| [551] | 91 | return NULL;                          /* failure */ | 
|---|
| [2] | 92 | } | 
|---|
|  | 93 |  | 
|---|
| [551] | 94 | PCNRITEM FindParentRecord(HWND hwndCnr, PCNRITEM pciC) | 
|---|
|  | 95 | { | 
|---|
| [2] | 96 |  | 
|---|
| [551] | 97 | PCNRITEM pciP = (PCNRITEM) NULL, pci = pciC; | 
|---|
| [2] | 98 |  | 
|---|
| [551] | 99 | if (pci) { | 
|---|
|  | 100 | for (;;) { | 
|---|
| [2] | 101 | pciP = WinSendMsg(hwndCnr, | 
|---|
| [551] | 102 | CM_QUERYRECORD, | 
|---|
|  | 103 | MPFROMP(pci), | 
|---|
|  | 104 | MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER)); | 
|---|
|  | 105 | if (pciP && (INT) pciP != -1) | 
|---|
|  | 106 | pci = pciP; | 
|---|
| [2] | 107 | else | 
|---|
| [551] | 108 | break; | 
|---|
| [2] | 109 | } | 
|---|
|  | 110 | } | 
|---|
|  | 111 | return pci; | 
|---|
|  | 112 | } | 
|---|
|  | 113 |  | 
|---|
| [551] | 114 | VOID ShowCnrRecord(HWND hwndCnr, PMINIRECORDCORE pmi) | 
|---|
|  | 115 | { | 
|---|
| [2] | 116 |  | 
|---|
| [551] | 117 | QUERYRECORDRECT qrecrct; | 
|---|
|  | 118 | RECTL rcl; | 
|---|
|  | 119 | RECTL rclViewport; | 
|---|
| [2] | 120 |  | 
|---|
| [551] | 121 | memset(&qrecrct, 0, sizeof(QUERYRECORDRECT)); | 
|---|
| [2] | 122 | qrecrct.cb = sizeof(QUERYRECORDRECT); | 
|---|
| [551] | 123 | qrecrct.pRecord = (PRECORDCORE) pmi; | 
|---|
| [2] | 124 | qrecrct.fsExtent = (CMA_ICON | CMA_TEXT | CMA_TREEICON); | 
|---|
| [551] | 125 | if (!WinSendMsg(hwndCnr, | 
|---|
| [1550] | 126 | CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct))) { | 
|---|
| [2] | 127 | qrecrct.fsExtent = CMA_TEXT | CMA_TREEICON; | 
|---|
| [551] | 128 | WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct)); | 
|---|
| [2] | 129 | } | 
|---|
|  | 130 | WinSendMsg(hwndCnr, | 
|---|
| [551] | 131 | CM_QUERYVIEWPORTRECT, | 
|---|
| [1549] | 132 | MPFROMP(&rclViewport), MPFROM2SHORT(CMA_WINDOW, TRUE)); | 
|---|
|  | 133 | //DbgMsg(pszSrcFile, __LINE__, "TOPPORT %i TOPRCL %i", rclViewport.yTop , rcl.yTop); | 
|---|
| [2] | 134 | WinSendMsg(hwndCnr, | 
|---|
| [551] | 135 | CM_SCROLLWINDOW, | 
|---|
| [1550] | 136 | MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(rcl.xRight - rclViewport.xRight)); | 
|---|
| [2] | 137 | WinSendMsg(hwndCnr, | 
|---|
| [551] | 138 | CM_SCROLLWINDOW, | 
|---|
| [1550] | 139 | MPFROMSHORT(CMA_VERTICAL), | 
|---|
|  | 140 | MPFROMLONG((rclViewport.yTop - (rcl.yTop) - 4))); | 
|---|
| [2] | 141 | } | 
|---|
| [793] | 142 |  | 
|---|
|  | 143 | #pragma alloc_text(FINDREC,FindCnrRecord,FindParentRecord,ShowCnrRecord) | 
|---|