source: trunk/dll/findrec.c@ 1505

Last change on this file since 1505 was 1434, checked in by Gregg Young, 16 years ago

Update show label or FS in tree to initialize as driveonly and fixed typo which caused rescan to fail after the value was changed. Renamed some variables.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1
2/***********************************************************************
3
4 $Id: findrec.c 1434 2009-06-22 22:52:05Z 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
19#define INCL_LONGLONG // dircnrs.h
20
21#include "fm3dll.h"
22#include "findrec.h"
23
24PCNRITEM FindCnrRecord(HWND hwndCnr, CHAR *filename, PCNRITEM pciParent,
25 BOOL partial, BOOL partmatch, BOOL noenv)
26{
27 SEARCHSTRING srch;
28 PCNRITEM pci;
29 register CHAR *file, *p;
30
31 if (partial) {
32 if (strlen(filename) > 3) {
33 file = strrchr(filename, '\\');
34 if (!file) {
35 file = strrchr(filename, ':');
36 if (file)
37 file++;
38 else
39 file = filename;
40 }
41 else
42 file++;
43 }
44 else
45 file = filename;
46 }
47 else
48 file = filename;
49 memset(&srch, 0, sizeof(SEARCHSTRING));
50 srch.cb = (ULONG) sizeof(SEARCHSTRING);
51 srch.pszSearch = (PSZ) file;
52 srch.fsPrefix = FALSE;
53 srch.fsCaseSensitive = FALSE;
54 srch.usView = CV_TREE; /* | CV_EXACTMATCH; */
55 if (!pciParent)
56 pciParent = (PCNRITEM) CMA_FIRST;
57 pci = WinSendMsg(hwndCnr,
58 CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pciParent));
59 while (pci && (INT) pci != -1) {
60 if (!noenv || (pci->flags & (RECFLAGS_ENV | RECFLAGS_UNDERENV)) == 0) {
61 if (!partmatch) { /* full name must match full name */
62 if (!stricmp(pci->pszFileName, filename))
63 return pci; /* success */
64 }
65 else { /* only root name must match */
66 if (strlen(pci->pszFileName) > 3) {
67 p = strrchr(pci->pszFileName, '\\');
68 if (!p) {
69 p = strrchr(pci->pszFileName, ':');
70 if (p)
71 p++;
72 else
73 p = pci->pszFileName;
74 }
75 else
76 p++;
77 }
78 else
79 p = pci->pszFileName;
80 if (!stricmp(p, file))
81 return pci; /* success */
82 }
83 }
84 pci = WinSendMsg(hwndCnr, CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pci));
85 }
86
87 return NULL; /* failure */
88}
89
90PCNRITEM FindParentRecord(HWND hwndCnr, PCNRITEM pciC)
91{
92
93 PCNRITEM pciP = (PCNRITEM) NULL, pci = pciC;
94
95 if (pci) {
96 for (;;) {
97 pciP = WinSendMsg(hwndCnr,
98 CM_QUERYRECORD,
99 MPFROMP(pci),
100 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
101 if (pciP && (INT) pciP != -1)
102 pci = pciP;
103 else
104 break;
105 }
106 }
107 return pci;
108}
109
110VOID ShowCnrRecord(HWND hwndCnr, PMINIRECORDCORE pmi)
111{
112
113 QUERYRECORDRECT qrecrct;
114 RECTL rcl;
115 RECTL rclViewport;
116
117 memset(&qrecrct, 0, sizeof(QUERYRECORDRECT));
118 qrecrct.cb = sizeof(QUERYRECORDRECT);
119 qrecrct.pRecord = (PRECORDCORE) pmi;
120 qrecrct.fsExtent = (CMA_ICON | CMA_TEXT | CMA_TREEICON);
121 if (!WinSendMsg(hwndCnr,
122 CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct))) {
123 qrecrct.fsExtent = CMA_TEXT | CMA_TREEICON;
124 WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct));
125 }
126 WinSendMsg(hwndCnr,
127 CM_QUERYVIEWPORTRECT,
128 MPFROMP(&rclViewport), MPFROM2SHORT(CMA_WINDOW, FALSE));
129 WinSendMsg(hwndCnr,
130 CM_SCROLLWINDOW,
131 MPFROMSHORT(CMA_VERTICAL),
132 MPFROMLONG((rclViewport.yTop - rcl.yTop) - 4));
133 WinSendMsg(hwndCnr,
134 CM_SCROLLWINDOW,
135 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(rcl.xRight - rclViewport.xRight));
136}
137
138#pragma alloc_text(FINDREC,FindCnrRecord,FindParentRecord,ShowCnrRecord)
Note: See TracBrowser for help on using the repository browser.