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