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 256 by douglas, 2003-08-15T21:56:17-07:00 vs.
Revision 278 by douglas, 2003-08-25T00:29:00-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.h,v 1.2 2003/08/16 04:56:17 douglas Exp $
5 > // $Id: VTBFileUtil2.h,v 1.12 2003/08/25 07:29:00 douglas Exp $
6  
7   #ifndef _VTBFileUtil_h_
8   #define _VTBFileUtil_h_
# Line 12 | Line 12
12   #endif // _DEBUG
13  
14   #include <iostream>
15 + #include <locale>
16   #include <string>
17   #include <sstream>
18   #include <cctype>
19   #include <vector>
20 + #include <set>
21 + #include <map>
22 + #include <cstdlib>
23  
24   #include <windows.h>
25 + #include <windowsx.h>
26 + #include <commctrl.h>
27 + #include <objbase.h>
28 + #include <shlobj.h>
29 + #include <shlwapi.h>
30 +
31 + #include "resource.h"
32  
33   using namespace std;
34  
35 + enum Mode { none, disc, scan };
36 + struct Gui
37 + {
38 +        HINSTANCE instance;
39 +        HICON icon;
40 +        int show;
41 + };
42 +
43   extern bool debug;
44   extern string program;
45   extern string programName;
46   extern string programVersion;
47 + extern Gui gui;
48 +
49 + void usage(HWND parent = NULL);
50 + void version(HWND parent = NULL);
51 +
52 + inline string toAnsi(const wstring& wide)
53 + {
54 +        LPSTR buffer = new CHAR[wide.length() + 1];
55 +
56 +        WideCharToMultiByte(CP_ACP, 0, wide.c_str(), wide.length() + 1, buffer,
57 +                wide.length() + 1, NULL, NULL);
58 +
59 +        return buffer;
60 + }
61 +
62 + inline wstring toWide(const string& ansi)
63 + {
64 +        LPWSTR buffer = new WCHAR[ansi.length() + 1];
65 +
66 +        MultiByteToWideChar(CP_ACP, 0, ansi.c_str(), ansi.length() + 1, buffer,
67 +                ansi.length() + 1);
68 +
69 +        return buffer;
70 + }
71  
29 void usage(HINSTANCE instance, HWND parent = NULL);
30 void version(HINSTANCE instance, HWND parent = NULL);
72   inline void center(HWND window)
73   {
74          RECT rect, dialog, desktop;
# Line 44 | Line 85 | inline void center(HWND window)
85                  + (rect.bottom / 2), 0, 0, SWP_NOSIZE);
86   }
87  
88 + inline void error(HWND parent = NULL)
89 + {
90 +        LPVOID message;
91 +
92 +        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
93 +                FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
94 +                LPTSTR(&message), 0, NULL);
95 +        MessageBox(parent, LPCTSTR(message), programName.c_str(), MB_ICONERROR);
96 +        LocalFree(message);
97 + }
98 +
99 + inline string format(DWORD value)
100 + {
101 +        ostringstream buffer;
102 +
103 +        buffer << value;
104 +
105 +        string format = buffer.str();
106 +
107 +        for (int index = format.length(), number = 0; index > 0; index -= 3,
108 +                number += 3)
109 +        {
110 +                if (index - 3 > 0)
111 +                {
112 +                        format.insert(index - 3, 1, ',');
113 +                }
114 +        }
115 +
116 +        return format;
117 + }
118 +
119   #endif // _VTBFileUtil_h_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines