2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: VTBFileUtil2.h,v 1.6 2003/08/17 00:43:49 douglas Exp $ |
5 |
> |
// $Id: VTBFileUtil2.h,v 1.13 2003/08/25 08:08:18 douglas Exp $ |
6 |
|
|
7 |
|
#ifndef _VTBFileUtil_h_ |
8 |
|
#define _VTBFileUtil_h_ |
16 |
|
#include <sstream> |
17 |
|
#include <cctype> |
18 |
|
#include <vector> |
19 |
+ |
#include <set> |
20 |
+ |
#include <map> |
21 |
|
#include <cstdlib> |
22 |
|
|
23 |
|
#include <windows.h> |
24 |
+ |
#include <windowsx.h> |
25 |
|
#include <commctrl.h> |
26 |
|
#include <objbase.h> |
27 |
|
#include <shlobj.h> |
28 |
+ |
#include <shlwapi.h> |
29 |
|
|
30 |
|
#include "resource.h" |
31 |
|
|
36 |
|
{ |
37 |
|
HINSTANCE instance; |
38 |
|
HICON icon; |
39 |
< |
UINT_PTR tips; |
39 |
> |
int show; |
40 |
|
}; |
41 |
|
|
42 |
|
extern bool debug; |
47 |
|
|
48 |
|
void usage(HWND parent = NULL); |
49 |
|
void version(HWND parent = NULL); |
50 |
+ |
|
51 |
|
inline string toAnsi(const wstring& wide) |
52 |
|
{ |
53 |
|
LPSTR buffer = new CHAR[wide.length() + 1]; |
57 |
|
|
58 |
|
return buffer; |
59 |
|
} |
60 |
+ |
|
61 |
|
inline wstring toWide(const string& ansi) |
62 |
|
{ |
63 |
|
LPWSTR buffer = new WCHAR[ansi.length() + 1]; |
67 |
|
|
68 |
|
return buffer; |
69 |
|
} |
70 |
+ |
|
71 |
|
inline void center(HWND window) |
72 |
|
{ |
73 |
|
RECT rect, dialog, desktop; |
83 |
|
SetWindowPos(window, HWND_TOP, desktop.left + (rect.right / 2), desktop.top |
84 |
|
+ (rect.bottom / 2), 0, 0, SWP_NOSIZE); |
85 |
|
} |
86 |
< |
void tooltip(HWND tool, const string& tip); |
86 |
> |
|
87 |
> |
inline void error(HWND parent = NULL) |
88 |
> |
{ |
89 |
> |
LPVOID message; |
90 |
> |
|
91 |
> |
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | |
92 |
> |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, |
93 |
> |
LPTSTR(&message), 0, NULL); |
94 |
> |
MessageBox(parent, LPCTSTR(message), programName.c_str(), MB_ICONERROR); |
95 |
> |
LocalFree(message); |
96 |
> |
} |
97 |
> |
|
98 |
> |
inline string format(DWORD value) |
99 |
> |
{ |
100 |
> |
ostringstream buffer; |
101 |
> |
|
102 |
> |
buffer << value; |
103 |
> |
|
104 |
> |
string format = buffer.str(); |
105 |
> |
|
106 |
> |
for (int index = format.length(), number = 0; index > 0; index -= 3, |
107 |
> |
number += 3) |
108 |
> |
{ |
109 |
> |
if (index - 3 > 0) |
110 |
> |
{ |
111 |
> |
format.insert(index - 3, 1, ','); |
112 |
> |
} |
113 |
> |
} |
114 |
> |
|
115 |
> |
return format; |
116 |
> |
} |
117 |
|
|
118 |
|
#endif // _VTBFileUtil_h_ |