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