ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/VTBFileUtil2.h
Revision: 277
Committed: 2003-08-24T00:31:45-07:00 (21 years, 10 months ago) by douglas
Content type: text/x-c
File size: 1993 byte(s)
Log Message:
Did work.

File Contents

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