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