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 265 by douglas, 2003-08-16T20:55:39-07:00 vs.
Revision 295 by douglas, 2003-09-11T21:26:54-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: VTBFileUtil2.h,v 1.7 2003/08/17 03:55:39 douglas Exp $
5 > // $Id: VTBFileUtil2.h,v 1.18 2003/09/12 04:26:54 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 + #define STRSAFE_LIB
35 + #define STRSAFE_NO_CB_FUNCTIONS
36 +
37 + #include <strsafe.h>
38  
39   #include "resource.h"
40  
# Line 34 | Line 45 | struct Gui
45   {
46          HINSTANCE instance;
47          HICON icon;
48 <        UINT_PTR tips;
48 >        int show;
49   };
50  
51   extern bool debug;
# Line 45 | Line 56 | extern Gui gui;
56  
57   void usage(HWND parent = NULL);
58   void version(HWND parent = NULL);
59 +
60 + inline string toLower(const string& mixed)
61 + {
62 +        string lower;
63 +
64 +        for (unsigned index = 0; index < mixed.length(); index++)
65 +        {
66 +                lower += tolower(mixed[index]);
67 +        }
68 +
69 +        return lower;
70 + }
71 +
72   inline string toAnsi(const wstring& wide)
73   {
74          LPSTR buffer = new CHAR[wide.length() + 1];
# Line 54 | Line 78 | inline string toAnsi(const wstring& wide
78  
79          return buffer;
80   }
81 +
82   inline wstring toWide(const string& ansi)
83   {
84          LPWSTR buffer = new WCHAR[ansi.length() + 1];
# Line 63 | Line 88 | inline wstring toWide(const string& ansi
88  
89          return buffer;
90   }
91 +
92   inline void center(HWND window)
93   {
94          RECT rect, dialog, desktop;
# Line 78 | Line 104 | inline void center(HWND window)
104          SetWindowPos(window, HWND_TOP, desktop.left + (rect.right / 2), desktop.top
105                  + (rect.bottom / 2), 0, 0, SWP_NOSIZE);
106   }
107 < void tooltip(HWND tool, const string& tip);
107 >
108 > inline void error(HWND parent = NULL, LONG code = ERROR_SUCCESS)
109 > {
110 >        LPVOID message;
111 >
112 >        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
113 >                NULL, code == ERROR_SUCCESS ? GetLastError() : code, 0,
114 >                LPTSTR(&message), 0, NULL);
115 >        MessageBox(parent, LPCTSTR(message), programName.c_str(), MB_ICONERROR);
116 >        LocalFree(message);
117 > }
118 >
119 > inline string format(DWORD value)
120 > {
121 >        ostringstream buffer;
122 >
123 >        buffer << value;
124 >
125 >        string format = buffer.str();
126 >
127 >        for (int index = format.length(), number = 0; index > 0; index -= 3,
128 >                number += 3)
129 >        {
130 >                if (index - 3 > 0)
131 >                {
132 >                        format.insert(index - 3, 1, ',');
133 >                }
134 >        }
135 >
136 >        return format;
137 > }
138  
139   #endif // _VTBFileUtil_h_

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines