ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/VTBFileUtil2.h
Revision: 271
Committed: 2003-08-19T22:49:34-07:00 (21 years, 10 months ago) by douglas
Content type: text/x-c
File size: 1960 byte(s)
Log Message:
Start page of ScanUtility pretty much works.

File Contents

# User Rev Content
1 douglas 255 // Vance Thrift and Biller File Utility 2
2     //
3     // Douglas Thrift
4     //
5 douglas 271 // $Id: VTBFileUtil2.h,v 1.10 2003/08/20 05:49:34 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 271 #include <shlwapi.h>
28 douglas 255
29 douglas 262 #include "resource.h"
30    
31 douglas 255 using namespace std;
32    
33 douglas 262 enum Mode { none, disc, scan };
34     struct Gui
35     {
36     HINSTANCE instance;
37     HICON icon;
38     };
39    
40 douglas 255 extern bool debug;
41     extern string program;
42     extern string programName;
43 douglas 256 extern string programVersion;
44 douglas 262 extern Gui gui;
45 douglas 255
46 douglas 259 void usage(HWND parent = NULL);
47     void version(HWND parent = NULL);
48 douglas 264 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 douglas 256 inline void center(HWND window)
67     {
68     RECT rect, dialog, desktop;
69 douglas 255
70 douglas 256 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 douglas 269 inline void error(void)
82     {
83     LPVOID message;
84 douglas 256
85 douglas 269 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
86     FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
87     LPTSTR(&message), 0, NULL);
88     MessageBox(NULL, LPCTSTR(message), programName.c_str(), MB_ICONERROR);
89     LocalFree(message);
90     }
91    
92 douglas 255 #endif // _VTBFileUtil_h_