source: trunk/dll/findrec.c@ 1871

Last change on this file since 1871 was 1871, checked in by Gregg Young, 10 years ago

Create CollapseAll and modify ExpandAll to reduce code overhead both to try and speed drive expansion. Change ExpandAll to allow it to loop in UM_EXPAND until until drive is completely expanded. Changes were need to work with Flesh, Stubby and UnFlesh being moved to a thread. Add code for Flesh to skip the directory entry added by Stubby (eliminate use of NULL/Nullstr pszFileNames by Stubby). Add code in Stubby to insert a complete container item. Add a flag to indicate when a directory needed to be Fleshed. Get expand and switch code to work with Flesh, UnFlesh and Stubby running on a thread. Loop and idle ExpandAll; Move tree expand to a thread; Have ShowTreeRec wait for the Flesh thread. Add a correction factor so directories don't get placed above the top of the tree container when a large drive has been expanded. Debug is mostly still in but all turned off.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
RevLine 
[793]1
2/***********************************************************************
3
4 $Id: findrec.c 1871 2015-09-20 22:57:02Z gyoung $
5
6 Copyright (c) 1993-98 M. Kimes
[1854]7 Copyright (c) 2003, 2015 Steven H.Levine
[793]8
9 Find records
10
11 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[1361]12 28 Dec 08 GKY Containers will only scroll to the right if needed to show end of selected
[1865]13 item and will scroll left to eliminate space after a selected item. Ticket 204
[1854]14 06 Aug 15 SHL Clean up and comment
[1865]15 23 Aug 15 SHL Protect FindCnrRecord filename arg
[1871]16 20 Sep 15 GKY Add a correction factor so directories don't get placed above the top of the
17 tree container when a large drive has been expanded.
[793]18
19***********************************************************************/
20
[907]21#include <string.h>
[1549]22#include <stdlib.h>
[2]23
[907]24#define INCL_LONGLONG // dircnrs.h
25
[2]26#include "fm3dll.h"
[1160]27#include "findrec.h"
[1549]28#include "errutil.h" // Dos_Error...
[2]29
[1549]30//static PSZ pszSrcFile = __FILE__;
31
[1865]32PCNRITEM FindCnrRecord(HWND hwndCnr, PCSZ filename, PCNRITEM pciParent,
[551]33 BOOL partial, BOOL partmatch, BOOL noenv)
34{
35 SEARCHSTRING srch;
36 PCNRITEM pci;
[1865]37 PCSZ file;
38 PCSZ p;
[2]39
[551]40 if (partial) {
41 if (strlen(filename) > 3) {
42 file = strrchr(filename, '\\');
43 if (!file) {
44 file = strrchr(filename, ':');
45 if (file)
46 file++;
47 else
48 file = filename;
[2]49 }
50 else
[551]51 file++;
[2]52 }
53 else
54 file = filename;
55 }
56 else
57 file = filename;
[551]58 memset(&srch, 0, sizeof(SEARCHSTRING));
59 srch.cb = (ULONG) sizeof(SEARCHSTRING);
60 srch.pszSearch = (PSZ) file;
[2]61 srch.fsPrefix = FALSE;
62 srch.fsCaseSensitive = FALSE;
[1854]63 srch.usView = CV_TREE;
[551]64 if (!pciParent)
65 pciParent = (PCNRITEM) CMA_FIRST;
[2]66 pci = WinSendMsg(hwndCnr,
[1871]67 CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pciParent));
68 //DbgMsg(pszSrcFile, __LINE__,"FindCnrItem pciParent %p pci %p file %s", pciParent,
69 // pci, file);
[551]70 while (pci && (INT) pci != -1) {
71 if (!noenv || (pci->flags & (RECFLAGS_ENV | RECFLAGS_UNDERENV)) == 0) {
[1854]72 // CNRITEM for file/directory
73 if (!partmatch) { // file name must match full name
[730]74 if (!stricmp(pci->pszFileName, filename))
[1854]75 return pci; // got full match
[2]76 }
[1673]77 else { // only root name must match
[1854]78 // partial match
79 if (strlen(pci->pszFileName) <= 3)
80 p = pci->pszFileName; // Root
81 else {
[730]82 p = strrchr(pci->pszFileName, '\\');
[1854]83 if (p)
84 p++; // After slash
85 else {
[730]86 p = strrchr(pci->pszFileName, ':');
[551]87 if (p)
[1854]88 p++; // After colon
[551]89 else
[1854]90 p = pci->pszFileName; // Must be bare file name
[551]91 }
92 }
93 if (!stricmp(p, file))
[1854]94 return pci; // got partial match
[2]95 }
96 }
[551]97 pci = WinSendMsg(hwndCnr, CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pci));
[2]98 }
[689]99
[1673]100 return NULL; // failure
[2]101}
102
[551]103PCNRITEM FindParentRecord(HWND hwndCnr, PCNRITEM pciC)
104{
[2]105
[551]106 PCNRITEM pciP = (PCNRITEM) NULL, pci = pciC;
[2]107
[551]108 if (pci) {
109 for (;;) {
[2]110 pciP = WinSendMsg(hwndCnr,
[551]111 CM_QUERYRECORD,
112 MPFROMP(pci),
113 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
114 if (pciP && (INT) pciP != -1)
115 pci = pciP;
[2]116 else
[551]117 break;
[2]118 }
119 }
120 return pci;
121}
122
[551]123VOID ShowCnrRecord(HWND hwndCnr, PMINIRECORDCORE pmi)
124{
[2]125
[551]126 QUERYRECORDRECT qrecrct;
127 RECTL rcl;
128 RECTL rclViewport;
[1871]129 RECTL rclFirst;
130 RECTL rclLast;
131 PMINIRECORDCORE pmiFirst;
132 PMINIRECORDCORE pmiLast;
133 INT correction;
[2]134
[1871]135 pmiFirst = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(NULL),
136 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
137 pmiLast = WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(NULL),
138 MPFROM2SHORT(CMA_LAST, CMA_ITEMORDER));
139 WinSendMsg(hwndCnr,
140 CM_QUERYVIEWPORTRECT,
141 MPFROMP(&rclViewport), MPFROM2SHORT(CMA_WINDOW , TRUE));
[551]142 memset(&qrecrct, 0, sizeof(QUERYRECORDRECT));
[2]143 qrecrct.cb = sizeof(QUERYRECORDRECT);
[551]144 qrecrct.pRecord = (PRECORDCORE) pmi;
[2]145 qrecrct.fsExtent = (CMA_ICON | CMA_TEXT | CMA_TREEICON);
[551]146 if (!WinSendMsg(hwndCnr,
[1865]147 CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct))) {
[2]148 qrecrct.fsExtent = CMA_TEXT | CMA_TREEICON;
[551]149 WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct));
[2]150 }
[1871]151 qrecrct.pRecord = (PRECORDCORE) pmiFirst;
152 WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rclFirst), MPFROMP(&qrecrct));
153 qrecrct.pRecord = (PRECORDCORE) pmiLast;
154 WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rclLast), MPFROMP(&qrecrct));
155 correction = 5 + ((abs(rclFirst.yTop) + abs(rclLast.yTop)) / 22500);
[2]156 WinSendMsg(hwndCnr,
[1871]157 CM_SCROLLWINDOW,
158 MPFROMSHORT(CMA_VERTICAL),
159 MPFROMLONG((rclViewport.yTop - (rcl.yTop) - correction)));
160#if 0
161 DbgMsg(pszSrcFile, __LINE__, "RECTLFIRST %i RECTLLAST %i %p",
162 rclFirst.yTop, rclLast.yTop, pmiLast);
163 DbgMsg(pszSrcFile, __LINE__, "TOPPORT %i TOPRCL %i RIGHTRCL %i",
164 rclViewport.yTop , rcl.yTop, rcl.xRight);
165#endif
[2]166 WinSendMsg(hwndCnr,
[551]167 CM_SCROLLWINDOW,
[1854]168 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(rcl.xRight - rclViewport.xRight));
[1871]169
[2]170}
[793]171
172#pragma alloc_text(FINDREC,FindCnrRecord,FindParentRecord,ShowCnrRecord)
Note: See TracBrowser for help on using the repository browser.