1 |
// Vance Thrift and Biller File Utility 2 |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id: VTBFileUtil2.h,v 1.9 2003/08/19 08:19:24 douglas Exp $ |
6 |
|
7 |
#ifndef _VTBFileUtil_h_ |
8 |
#define _VTBFileUtil_h_ |
9 |
|
10 |
#ifdef _DEBUG |
11 |
#pragma warning(disable:4786) |
12 |
#endif // _DEBUG |
13 |
|
14 |
#include <iostream> |
15 |
#include <string> |
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 <commctrl.h> |
25 |
#include <objbase.h> |
26 |
#include <shlobj.h> |
27 |
|
28 |
#include "resource.h" |
29 |
|
30 |
using namespace std; |
31 |
|
32 |
enum Mode { none, disc, scan }; |
33 |
struct Gui |
34 |
{ |
35 |
HINSTANCE instance; |
36 |
HICON icon; |
37 |
}; |
38 |
|
39 |
extern bool debug; |
40 |
extern string program; |
41 |
extern string programName; |
42 |
extern string programVersion; |
43 |
extern Gui gui; |
44 |
|
45 |
void usage(HWND parent = NULL); |
46 |
void version(HWND parent = NULL); |
47 |
inline string toAnsi(const wstring& wide) |
48 |
{ |
49 |
LPSTR buffer = new CHAR[wide.length() + 1]; |
50 |
|
51 |
WideCharToMultiByte(CP_ACP, 0, wide.c_str(), wide.length() + 1, buffer, |
52 |
wide.length() + 1, NULL, NULL); |
53 |
|
54 |
return buffer; |
55 |
} |
56 |
inline wstring toWide(const string& ansi) |
57 |
{ |
58 |
LPWSTR buffer = new WCHAR[ansi.length() + 1]; |
59 |
|
60 |
MultiByteToWideChar(CP_ACP, 0, ansi.c_str(), ansi.length() + 1, buffer, |
61 |
ansi.length() + 1); |
62 |
|
63 |
return buffer; |
64 |
} |
65 |
inline void center(HWND window) |
66 |
{ |
67 |
RECT rect, dialog, desktop; |
68 |
|
69 |
GetWindowRect(GetDesktopWindow(), &desktop); |
70 |
GetWindowRect(window, &dialog); |
71 |
CopyRect(&rect, &desktop); |
72 |
|
73 |
OffsetRect(&dialog, -dialog.left, -dialog.top); |
74 |
OffsetRect(&rect, -rect.left, -rect.top); |
75 |
OffsetRect(&rect, -dialog.right, -dialog.bottom); |
76 |
|
77 |
SetWindowPos(window, HWND_TOP, desktop.left + (rect.right / 2), desktop.top |
78 |
+ (rect.bottom / 2), 0, 0, SWP_NOSIZE); |
79 |
} |
80 |
inline void error(void) |
81 |
{ |
82 |
LPVOID message; |
83 |
|
84 |
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | |
85 |
FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, |
86 |
LPTSTR(&message), 0, NULL); |
87 |
MessageBox(NULL, LPCTSTR(message), programName.c_str(), MB_ICONERROR); |
88 |
LocalFree(message); |
89 |
} |
90 |
|
91 |
#endif // _VTBFileUtil_h_ |