source: trunk/dll/findrec.c@ 1200

Last change on this file since 1200 was 1160, checked in by John Small, 17 years ago

Ticket 187: Draft 1: Functions only

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