source: trunk/dll/findrec.c@ 1854

Last change on this file since 1854 was 1854, checked in by Steven Levine, 10 years ago

Clean up and comment

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