1 |
// Vance Thrift and Biller File Utility 2 |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id: VTBFileUtil2.h,v 1.7 2003/08/17 03:55:39 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 |
UINT_PTR tips; |
38 |
}; |
39 |
|
40 |
extern bool debug; |
41 |
extern string program; |
42 |
extern string programName; |
43 |
extern string programVersion; |
44 |
extern Gui gui; |
45 |
|
46 |
void usage(HWND parent = NULL); |
47 |
void version(HWND parent = NULL); |
48 |
inline string toAnsi(const wstring& wide) |
49 |
{ |
50 |
LPSTR buffer = new CHAR[wide.length() + 1]; |
51 |
|
52 |
WideCharToMultiByte(CP_ACP, 0, wide.c_str(), wide.length() + 1, buffer, |
53 |
wide.length() + 1, NULL, NULL); |
54 |
|
55 |
return buffer; |
56 |
} |
57 |
inline wstring toWide(const string& ansi) |
58 |
{ |
59 |
LPWSTR buffer = new WCHAR[ansi.length() + 1]; |
60 |
|
61 |
MultiByteToWideChar(CP_ACP, 0, ansi.c_str(), ansi.length() + 1, buffer, |
62 |
ansi.length() + 1); |
63 |
|
64 |
return buffer; |
65 |
} |
66 |
inline void center(HWND window) |
67 |
{ |
68 |
RECT rect, dialog, desktop; |
69 |
|
70 |
GetWindowRect(GetDesktopWindow(), &desktop); |
71 |
GetWindowRect(window, &dialog); |
72 |
CopyRect(&rect, &desktop); |
73 |
|
74 |
OffsetRect(&dialog, -dialog.left, -dialog.top); |
75 |
OffsetRect(&rect, -rect.left, -rect.top); |
76 |
OffsetRect(&rect, -dialog.right, -dialog.bottom); |
77 |
|
78 |
SetWindowPos(window, HWND_TOP, desktop.left + (rect.right / 2), desktop.top |
79 |
+ (rect.bottom / 2), 0, 0, SWP_NOSIZE); |
80 |
} |
81 |
void tooltip(HWND tool, const string& tip); |
82 |
|
83 |
#endif // _VTBFileUtil_h_ |