root/trunk/RDragDropFiles.h

Revision 5, 4.2 kB (checked in by qbert, 6 years ago)

Initial ( and last :( ) commit

Line 
1 // RDragDropFiles.h: interface for the RDragDropFiles class.
2 //
3 /*
4     Author:         Richard Chambers, rickcham@mindspring.com
5
6     Copyright:      Richard Chambers, 2002
7
8     Version:        1.0
9
10     Rights of Use:  This source code may be used by anyone for any reason
11                     so long as the copyright information is maintained.
12
13                     There is no warranty, express or implied, as to fitness
14                     of purpose nor is there any other warranty, expressed
15                     or implied, as to correct functioning.
16
17                     This software depends on the existance of two functions
18                     in the Windows API as well as the correct function of
19                     those functions.  See the Requires section below.
20
21     Requires:       RDragDropFiles.cpp containing the class declaration.
22                     DragQueryFile function from the Windows API.
23                     Client must provide a correct HDROP handle to the constructor.
24                     Client must initialize file drop using DragAcceptFiles.
25
26     Assumptions:    If debug is turned on, the macro _DEBUG is defined and ASSERT
27                     is enabled.  If debug is turned off, the macro _DEBUG is
28                     undefined and ASSERT is disabled.
29
30                     The DragQueryFile Windows API function remains unchanged
31                     across Windows versions (Windows 95/98/ME/NT/2000).
32
33     Edit History:
34
35  */
36
37 //////////////////////////////////////////////////////////////////////
38
39 #if !defined(AFX_RDRAGDROPFILES_H__D7D93FAA_AB71_4356_BF4F_884F871493D0__INCLUDED_)
40 #define AFX_RDRAGDROPFILES_H__D7D93FAA_AB71_4356_BF4F_884F871493D0__INCLUDED_
41
42 #if _MSC_VER > 1000
43 #pragma once
44 #endif // _MSC_VER > 1000
45
46 namespace rjc {
47     class RDragDropFiles 
48     {
49     public:
50         /*
51             We force the user to provide an HDROP handle for the constructor.
52
53             We overload the operator () to provide a method for checking if there
54             are any more files in the list when iterating over the list using
55             sNextFile.  You could also do a check on the IsEmpty method of CString
56             after calling one of sFirstFile, sNextFile, or sCurrFile.
57
58             The IsEmpty method is used to determine if there are any files in
59             the file list.  It is NOT used to see if we have reached the end
60             of the file list when iterating using the sNextFile method.
61
62             The Reset method resets the file list position indicator to the
63             beginning of the list.  If you do a Reset and then a sNextFile,
64             you will get the first file in the list as if you had used sFirstFile.
65
66             The Clear method is used drop the association between the object and
67             the HDROP handle provided.  This means that if you use the Clear
68             method, you are responsible for file drag and drop cleanup.
69             You must explicitly use the DragFinish function for this cleanup
70             rather than letting the RDragDropFiles object do it for you.
71          */
72         RDragDropFiles(HDROP hDrop);
73         virtual ~RDragDropFiles();
74         UINT uCount (void);
75         CString & sFirstFile (CString & sBuff);
76         CString & sNextFile (CString & sBuff);
77         CString & sCurrFile (CString & sBuff);
78         boolean operator () (void);
79         boolean IsEmpty (void);
80         void    Reset (void);
81         void    Clear (void);
82
83     protected:
84         // we will not allow the compiler to create a
85         // copy constructor or an assignment constructor.
86         // Each object should be unique due to hDropFiles
87         // being unique.  The destructor for the object
88         // will release the drop file resources so there
89         // must only be one unique object per hDropFiles.
90         RDragDropFiles (RDragDropFiles &dr);
91         RDragDropFiles & operator = (RDragDropFiles &dr);
92
93     protected:
94         UINT nFiles;        // number of files from hDropInfo
95         UINT iPosition;     // current position in list of files
96         HDROP hDropInfo;    // copy of HDROP from OnDropFiles
97
98     };
99 };
100
101 #ifndef _DEBUG
102
103 //  debug versions of these are in RDragDropFiles.cpp
104 //  comments for these functions are also in RDragDropFiles.cpp
105 inline boolean rjc::RDragDropFiles::operator () () { return (hDropInfo && (iPosition < nFiles)); }
106 inline boolean rjc::RDragDropFiles::IsEmpty () { return (!hDropInfo || (nFiles < 1));}
107 inline void    rjc::RDragDropFiles::Reset () {iPosition = 0;}
108 inline UINT  rjc::RDragDropFiles::uCount () { return nFiles; }
109 inline void  rjc::RDragDropFiles::Clear () { hDropInfo = 0; nFiles = 0; }
110 #endif
111
112 #endif // !defined(AFX_RDRAGDROPFILES_H__D7D93FAA_AB71_4356_BF4F_884F871493D0__INCLUDED_)
Note: See TracBrowser for help on using the browser.