ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/VTBFileUtil2.h
(Generate patch)

Comparing trunk/VTBFileUtil2/VTBFileUtil2.h (file contents):
Revision 257 by douglas, 2003-08-15T23:44:42-07:00 vs.
Revision 292 by douglas, 2003-09-08T18:43:28-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.h,v 1.3 2003/08/16 06:44:42 douglas Exp $
5 > // $Id: VTBFileUtil2.h,v 1.17 2003/09/09 01:43:28 douglas Exp $
6  
7   #ifndef _VTBFileUtil_h_
8   #define _VTBFileUtil_h_
# Line 14 | Line 14
14   #include <iostream>
15   #include <string>
16   #include <sstream>
17 + #include <fstream>
18   #include <cctype>
19   #include <vector>
20 + #include <set>
21 + #include <map>
22 + #include <cstdlib>
23 +
24 + #define _WIN32_IE 0x0500
25  
26   #include <windows.h>
27 + #include <windowsx.h>
28   #include <commctrl.h>
29 + #include <objbase.h>
30 + #include <shlobj.h>
31 + #include <shlwapi.h>
32 + #include <richedit.h>
33 +
34 + #include "resource.h"
35  
36   using namespace std;
37  
38 + enum Mode { none, disc, scan };
39 + struct Gui
40 + {
41 +        HINSTANCE instance;
42 +        HICON icon;
43 +        int show;
44 + };
45 +
46   extern bool debug;
47   extern string program;
48   extern string programName;
49   extern string programVersion;
50 + extern Gui gui;
51  
52 < enum Mode { none, disc, scan };
52 > void usage(HWND parent = NULL);
53 > void version(HWND parent = NULL);
54 >
55 > inline string toLower(const string& mixed)
56 > {
57 >        string lower;
58 >
59 >        for (unsigned index = 0; index < mixed.length(); index++)
60 >        {
61 >                lower += tolower(mixed[index]);
62 >        }
63 >
64 >        return lower;
65 > }
66 >
67 > inline string toAnsi(const wstring& wide)
68 > {
69 >        LPSTR buffer = new CHAR[wide.length() + 1];
70 >
71 >        WideCharToMultiByte(CP_ACP, 0, wide.c_str(), wide.length() + 1, buffer,
72 >                wide.length() + 1, NULL, NULL);
73 >
74 >        return buffer;
75 > }
76 >
77 > inline wstring toWide(const string& ansi)
78 > {
79 >        LPWSTR buffer = new WCHAR[ansi.length() + 1];
80 >
81 >        MultiByteToWideChar(CP_ACP, 0, ansi.c_str(), ansi.length() + 1, buffer,
82 >                ansi.length() + 1);
83 >
84 >        return buffer;
85 > }
86  
32 void usage(HINSTANCE instance, HWND parent = NULL);
33 void version(HINSTANCE instance, HWND parent = NULL);
34 void choice(Mode& mode, HINSTANCE instance, HWND parent = NULL);
87   inline void center(HWND window)
88   {
89          RECT rect, dialog, desktop;
# Line 48 | Line 100 | inline void center(HWND window)
100                  + (rect.bottom / 2), 0, 0, SWP_NOSIZE);
101   }
102  
103 + inline void error(HWND parent = NULL, LONG code = ERROR_SUCCESS)
104 + {
105 +        LPVOID message;
106 +
107 +        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
108 +                NULL, code == ERROR_SUCCESS ? GetLastError() : code, 0,
109 +                LPTSTR(&message), 0, NULL);
110 +        MessageBox(parent, LPCTSTR(message), programName.c_str(), MB_ICONERROR);
111 +        LocalFree(message);
112 + }
113 +
114 + inline string format(DWORD value)
115 + {
116 +        ostringstream buffer;
117 +
118 +        buffer << value;
119 +
120 +        string format = buffer.str();
121 +
122 +        for (int index = format.length(), number = 0; index > 0; index -= 3,
123 +                number += 3)
124 +        {
125 +                if (index - 3 > 0)
126 +                {
127 +                        format.insert(index - 3, 1, ',');
128 +                }
129 +        }
130 +
131 +        return format;
132 + }
133 +
134   #endif // _VTBFileUtil_h_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines