2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: VTBFileUtil2.h,v 1.10 2003/08/20 05:49:34 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_ |
12 |
|
#endif // _DEBUG |
13 |
|
|
14 |
|
#include <iostream> |
15 |
+ |
#include <locale> |
16 |
|
#include <string> |
17 |
|
#include <sstream> |
18 |
|
#include <cctype> |
22 |
|
#include <cstdlib> |
23 |
|
|
24 |
|
#include <windows.h> |
25 |
+ |
#include <windowsx.h> |
26 |
|
#include <commctrl.h> |
27 |
|
#include <objbase.h> |
28 |
|
#include <shlobj.h> |
37 |
|
{ |
38 |
|
HINSTANCE instance; |
39 |
|
HICON icon; |
40 |
+ |
int show; |
41 |
|
}; |
42 |
|
|
43 |
|
extern bool debug; |
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]; |
58 |
|
|
59 |
|
return buffer; |
60 |
|
} |
61 |
+ |
|
62 |
|
inline wstring toWide(const string& ansi) |
63 |
|
{ |
64 |
|
LPWSTR buffer = new WCHAR[ansi.length() + 1]; |
68 |
|
|
69 |
|
return buffer; |
70 |
|
} |
71 |
+ |
|
72 |
|
inline void center(HWND window) |
73 |
|
{ |
74 |
|
RECT rect, dialog, desktop; |
84 |
|
SetWindowPos(window, HWND_TOP, desktop.left + (rect.right / 2), desktop.top |
85 |
|
+ (rect.bottom / 2), 0, 0, SWP_NOSIZE); |
86 |
|
} |
87 |
< |
inline void error(void) |
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(NULL, LPCTSTR(message), programName.c_str(), MB_ICONERROR); |
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_ |