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