ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/DiscBrowse.cxx
Revision: 282
Committed: 2003-08-25T23:41:12-07:00 (19 years, 3 months ago) by douglas
File size: 5796 byte(s)
Log Message:
Inheritance and such, ack evil window looping makes my head hurt.

File Contents

# User Rev Content
1 douglas 260 // Vance Thrift and Biller File Utility 2
2     //
3     // Douglas Thrift
4     //
5 douglas 282 // $Id: DiscBrowse.cxx,v 1.3 2003/08/26 06:41:12 douglas Exp $
6 douglas 260
7     #include "DiscBrowse.h"
8 douglas 265
9 douglas 282 DiscBrowse::DiscBrowse()
10     {
11     number = count++;
12    
13     browsers.insert(pair<unsigned, DiscBrowse*>(number, this));
14    
15     title = programName + " - Disc Browse";
16    
17     popup = CreatePopupMenu();
18    
19     MENUITEMINFO open, separator, properties;
20    
21     open.cbSize = sizeof(open);
22     open.fMask = MIIM_ID | MIIM_STATE | MIIM_TYPE;
23     open.fType = MFT_STRING;
24     open.fState = MFS_DEFAULT;
25     open.wID = 1;
26     open.dwTypeData = "&Open";
27     open.cch = 5;
28     separator.cbSize = sizeof(open);
29     separator.fMask = MIIM_TYPE;
30     separator.fType = MFT_SEPARATOR;
31     properties.cbSize = sizeof(open);
32     properties.fMask = MIIM_ID | MIIM_TYPE;
33     properties.fType = MFT_STRING;
34     properties.wID = 2;
35     properties.dwTypeData = "P&roperties";
36     properties.cch = 11;
37    
38     InsertMenuItem(popup, 0, TRUE, &open);
39     InsertMenuItem(popup, 1, TRUE, &separator);
40     InsertMenuItem(popup, 2, TRUE, &properties);
41    
42     // start
43     wizard[0].dwSize = sizeof(wizard[0]);
44     wizard[0].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
45     PSP_USEHEADERSUBTITLE;
46     wizard[0].hInstance = gui.instance;
47     wizard[0].pszTemplate = MAKEINTRESOURCE(IDD_BEGIN);
48     wizard[0].pszTitle = title.c_str();
49     wizard[0].pfnDlgProc = start;
50     wizard[0].lParam = number;
51     wizard[0].pszHeaderTitle = "Start";
52     wizard[0].pszHeaderSubTitle = "Change any settings before browsing.";
53    
54     // browse
55     wizard[1].dwSize = sizeof(wizard[1]);
56     wizard[1].dwFlags = PSP_DEFAULT | PSP_USETITLE | PSP_USEHEADERTITLE |
57     PSP_USEHEADERSUBTITLE;
58     wizard[1].hInstance = gui.instance;
59     wizard[1].pszTemplate = MAKEINTRESOURCE(IDD_BROWSE);
60     wizard[1].pszTitle = title.c_str();
61     wizard[1].pfnDlgProc = browse;
62     wizard[1].lParam = number;
63     wizard[1].pszHeaderTitle = "Browse";
64     wizard[1].pszHeaderSubTitle = "View documents on the disc.";
65     }
66    
67     DiscBrowse::~DiscBrowse()
68     {
69     DestroyMenu(popup);
70     browsers.erase(number);
71     }
72    
73 douglas 265 void DiscBrowse::run(void)
74     {
75 douglas 282 loadDir();
76    
77     PROPSHEETHEADER header;
78    
79     // header
80     header.dwSize = sizeof(header);
81     header.dwFlags = PSH_DEFAULT | PSH_HEADER | PSH_PROPSHEETPAGE |
82     PSH_USEICONID | PSH_WIZARD97 | PSH_WIZARDHASFINISH;
83     header.hwndParent = NULL;
84     header.hInstance = gui.instance;
85     header.pszIcon = MAKEINTRESOURCE(IDI_VTB_ICON);
86     header.nPages = 2;
87     header.nStartPage = 0;
88     header.ppsp = wizard;
89     header.pszbmHeader = MAKEINTRESOURCE(IDB_VTB_BMP);
90    
91     PropertySheet(&header);
92     saveDir();
93 douglas 265 }
94 douglas 282
95     unsigned DiscBrowse::count = 0;
96     map<unsigned, DiscBrowse*> DiscBrowse::browsers;
97    
98     map<HWND, DiscBrowse*> DiscBrowse::windows;
99    
100     void DiscBrowse::loadDir(void)
101     {
102     //
103     }
104    
105     void DiscBrowse::saveDir(void)
106     {
107     //
108     }
109    
110     void DiscBrowse::setDiscDir(HWND parent)
111     {
112     //
113     }
114    
115     DiscBrowse* DiscBrowse::which(HWND window)
116     {
117     map<HWND, DiscBrowse*>::iterator itor = windows.find(window);
118    
119     return itor->second;
120     }
121    
122     DiscBrowse* DiscBrowse::which(HWND window, LPARAM l)
123     {
124     LPPROPSHEETPAGE page = LPPROPSHEETPAGE(l);
125     map<unsigned, DiscBrowse*>::iterator itor = browsers.find(page->lParam);
126    
127     windows.insert(pair<HWND, DiscBrowse*>(window, itor->second));
128    
129     return itor->second;
130     }
131    
132     int DiscBrowse::browse(HWND dialog, UINT msg, LPARAM l, LPARAM d)
133     {
134     map<unsigned, DiscBrowse*>::iterator itor = browsers.find(LOWORD(d));
135     DiscBrowse* data = itor->second;
136    
137     switch (msg)
138     {
139     case BFFM_INITIALIZED:
140     center(dialog);
141     SendMessage(dialog, BFFM_SETOKTEXT, 0,
142     LPARAM(toWide("&Select").c_str()));
143     SendMessage(dialog, BFFM_SETEXPANDED, FALSE, CSIDL_DRIVES);
144     SendMessage(dialog, BFFM_SETSELECTION, TRUE,
145     LPARAM(data->discDir.c_str()));
146     break;
147     case BFFM_SELCHANGED:
148     {
149     IShellFolder* object;
150    
151     SHGetDesktopFolder(&object);
152    
153     STRRET thing;
154     char* folder;
155    
156     object->GetDisplayNameOf(LPCITEMIDLIST(l), SHGDN_FORPARSING,
157     &thing);
158     StrRetToStr(&thing, LPCITEMIDLIST(l), &folder);
159     SendMessage(dialog, BFFM_SETSTATUSTEXT, 0, LPARAM(folder));
160    
161     if (PathIsUNCServer(folder))
162     {
163     SendMessage(dialog, BFFM_ENABLEOK, 0, 0);
164     }
165    
166     CoTaskMemFree(folder);
167     object->Release();
168     }
169     break;
170     }
171    
172     return 0;
173     }
174    
175     INT_PTR DiscBrowse::start(HWND dialog, UINT msg, WPARAM w, LPARAM l)
176     {
177     DiscBrowse* data = which(dialog);
178    
179     switch (msg)
180     {
181     case WM_INITDIALOG:
182     center(GetParent(dialog));
183     SendMessage(GetParent(dialog), WM_SETICON, ICON_BIG, LPARAM(gui.icon));
184    
185     data = which(dialog, l);
186     break;
187     case WM_NOTIFY:
188     {
189     LPNMHDR nm = LPNMHDR(l);
190    
191     switch (nm->code)
192     {
193     case PSN_SETACTIVE:
194     PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_FINISH |
195     PSWIZB_NEXT);
196     break;
197     }
198     }
199     break;
200     }
201    
202     return FALSE;
203     }
204    
205     INT_PTR DiscBrowse::browse(HWND dialog, UINT msg, WPARAM w, LPARAM l)
206     {
207     DiscBrowse* data = which(dialog);
208    
209     switch (msg)
210     {
211     case WM_INITDIALOG:
212     data = which(dialog, l);
213    
214     {
215     LVCOLUMN number, name, file;
216    
217     number.mask = LVCF_TEXT | LVCF_WIDTH;
218     number.cx = 64;
219     number.pszText = "Number";
220     name.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
221     name.cx = 256;
222     name.pszText = "Client Name";
223     name.iSubItem = 1;
224     file.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
225     file.fmt = LVCFMT_IMAGE;
226     file.cx = 256;
227     file.pszText = "File Name";
228     file.iSubItem = 2;
229    
230     ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 0,
231     &number);
232     ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 1,
233     &name);
234     ListView_InsertColumn(GetDlgItem(dialog, IDC_BROWSE_DISC), 2,
235     &file);
236     }
237     break;
238     case WM_NOTIFY:
239     if (w == IDC_BROWSE_DISC)
240     {
241     LPNMITEMACTIVATE ni = LPNMITEMACTIVATE(l);
242    
243     switch (ni->hdr.code)
244     {
245     case NM_DBLCLK:
246     //
247     break;
248     }
249     }
250     else
251     {
252     LPNMHDR nm = LPNMHDR(l);
253    
254     switch (nm->code)
255     {
256     case PSN_SETACTIVE:
257     PropSheet_SetWizButtons(GetParent(dialog), PSWIZB_BACK |
258     PSWIZB_FINISH);
259     break;
260     }
261     }
262     break;
263     }
264    
265     return FALSE;
266     }