source: trunk/dll/findrec.c@ 1361

Last change on this file since 1361 was 1361, checked in by Gregg Young, 17 years ago

Eliminate container scroll right unless needed to show end of item; scholl back left to eleiminate space following an item. Ticket 204

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
RevLine 
[793]1
2/***********************************************************************
3
4 $Id: findrec.c 1361 2008-12-28 21:39:22Z gyoung $
5
6 Copyright (c) 1993-98 M. Kimes
[1347]7 Copyright (c) 2003, 2008 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
13 item and will scroll left to eliminate space after a selected item. Ticket 204
[793]14
15***********************************************************************/
16
[907]17#include <string.h>
[2]18
[907]19#define INCL_LONGLONG // dircnrs.h
20
[2]21#include "fm3dll.h"
[1160]22#include "findrec.h"
[2]23
[551]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;
[2]30
[551]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;
[2]40 }
41 else
[551]42 file++;
[2]43 }
44 else
45 file = filename;
46 }
47 else
48 file = filename;
[551]49 memset(&srch, 0, sizeof(SEARCHSTRING));
50 srch.cb = (ULONG) sizeof(SEARCHSTRING);
51 srch.pszSearch = (PSZ) file;
[2]52 srch.fsPrefix = FALSE;
53 srch.fsCaseSensitive = FALSE;
[551]54 srch.usView = CV_TREE; /* | CV_EXACTMATCH; */
55 if (!pciParent)
56 pciParent = (PCNRITEM) CMA_FIRST;
[2]57 pci = WinSendMsg(hwndCnr,
[551]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 */
[730]62 if (!stricmp(pci->pszFileName, filename))
[551]63 return pci; /* success */
[2]64 }
[551]65 else { /* only root name must match */
[730]66 if (strlen(pci->pszFileName) > 3) {
67 p = strrchr(pci->pszFileName, '\\');
[551]68 if (!p) {
[730]69 p = strrchr(pci->pszFileName, ':');
[551]70 if (p)
71 p++;
72 else
[730]73 p = pci->pszFileName;
[551]74 }
75 else
76 p++;
77 }
78 else
[730]79 p = pci->pszFileName;
[551]80 if (!stricmp(p, file))
81 return pci; /* success */
[2]82 }
83 }
[551]84 pci = WinSendMsg(hwndCnr, CM_SEARCHSTRING, MPFROMP(&srch), MPFROMP(pci));
[2]85 }
[689]86
[551]87 return NULL; /* failure */
[2]88}
89
[551]90PCNRITEM FindParentRecord(HWND hwndCnr, PCNRITEM pciC)
91{
[2]92
[551]93 PCNRITEM pciP = (PCNRITEM) NULL, pci = pciC;
[2]94
[551]95 if (pci) {
96 for (;;) {
[2]97 pciP = WinSendMsg(hwndCnr,
[551]98 CM_QUERYRECORD,
99 MPFROMP(pci),
100 MPFROM2SHORT(CMA_PARENT, CMA_ITEMORDER));
101 if (pciP && (INT) pciP != -1)
102 pci = pciP;
[2]103 else
[551]104 break;
[2]105 }
106 }
107 return pci;
108}
109
[551]110VOID ShowCnrRecord(HWND hwndCnr, PMINIRECORDCORE pmi)
111{
[2]112
[551]113 QUERYRECORDRECT qrecrct;
114 RECTL rcl;
115 RECTL rclViewport;
[2]116
[551]117 memset(&qrecrct, 0, sizeof(QUERYRECORDRECT));
[2]118 qrecrct.cb = sizeof(QUERYRECORDRECT);
[551]119 qrecrct.pRecord = (PRECORDCORE) pmi;
[2]120 qrecrct.fsExtent = (CMA_ICON | CMA_TEXT | CMA_TREEICON);
[551]121 if (!WinSendMsg(hwndCnr,
122 CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct))) {
[2]123 qrecrct.fsExtent = CMA_TEXT | CMA_TREEICON;
[551]124 WinSendMsg(hwndCnr, CM_QUERYRECORDRECT, MPFROMP(&rcl), MPFROMP(&qrecrct));
[2]125 }
126 WinSendMsg(hwndCnr,
[551]127 CM_QUERYVIEWPORTRECT,
128 MPFROMP(&rclViewport), MPFROM2SHORT(CMA_WINDOW, FALSE));
[2]129 WinSendMsg(hwndCnr,
[551]130 CM_SCROLLWINDOW,
131 MPFROMSHORT(CMA_VERTICAL),
132 MPFROMLONG((rclViewport.yTop - rcl.yTop) - 4));
[2]133 WinSendMsg(hwndCnr,
[551]134 CM_SCROLLWINDOW,
[1361]135 MPFROMSHORT(CMA_HORIZONTAL), MPFROMLONG(rcl.xRight - rclViewport.xRight));
[2]136}
[793]137
138#pragma alloc_text(FINDREC,FindCnrRecord,FindParentRecord,ShowCnrRecord)
Note: See TracBrowser for help on using the repository browser.