ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/VTBFileUtil2.h
Revision: 269
Committed: 2003-08-19T01:19:24-07:00 (21 years, 10 months ago) by douglas
Content type: text/x-c
File size: 1938 byte(s)
Log Message:
Hello nurse!

File Contents

# User Rev Content
1 douglas 255 // Vance Thrift and Biller File Utility 2
2     //
3     // Douglas Thrift
4     //
5 douglas 269 // $Id: VTBFileUtil2.h,v 1.9 2003/08/19 08:19:24 douglas Exp $
6 douglas 255
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 douglas 265 #include <set>
20     #include <map>
21 douglas 259 #include <cstdlib>
22 douglas 255
23     #include <windows.h>
24 douglas 257 #include <commctrl.h>
25 douglas 264 #include <objbase.h>
26     #include <shlobj.h>
27 douglas 255
28 douglas 262 #include "resource.h"
29    
30 douglas 255 using namespace std;
31    
32 douglas 262 enum Mode { none, disc, scan };
33     struct Gui
34     {
35     HINSTANCE instance;
36     HICON icon;
37     };
38    
39 douglas 255 extern bool debug;
40     extern string program;
41     extern string programName;
42 douglas 256 extern string programVersion;
43 douglas 262 extern Gui gui;
44 douglas 255
45 douglas 259 void usage(HWND parent = NULL);
46     void version(HWND parent = NULL);
47 douglas 264 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 douglas 256 inline void center(HWND window)
66     {
67     RECT rect, dialog, desktop;
68 douglas 255
69 douglas 256 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 douglas 269 inline void error(void)
81     {
82     LPVOID message;
83 douglas 256
84 douglas 269 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 douglas 255 #endif // _VTBFileUtil_h_