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