2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
< |
// $Id: Chooser.cxx,v 1.5 2003/08/18 22:25:29 douglas Exp $ |
5 |
> |
// $Id: Chooser.cxx,v 1.7 2003/08/19 08:19:24 douglas Exp $ |
6 |
|
|
7 |
|
#include "Chooser.h" |
8 |
|
|
29 |
|
return choice; |
30 |
|
} |
31 |
|
|
32 |
+ |
unsigned Chooser::count = 0; |
33 |
+ |
map<unsigned, Chooser*> Chooser::choosers; |
34 |
+ |
map<HWND, Chooser*> Chooser::windows; |
35 |
+ |
|
36 |
|
INT_PTR CALLBACK Chooser::window(HWND dialog, UINT msg, WPARAM w, LPARAM l) |
37 |
|
{ |
38 |
|
map<HWND, Chooser*>::iterator itor = windows.find(dialog); |
39 |
|
Chooser* data = itor->second; |
36 |
– |
Mode* choice = &data->choice; |
37 |
– |
bool* shortcut = &data->shortcut; |
40 |
|
|
41 |
|
switch (msg) |
42 |
|
{ |
54 |
|
switch (LOWORD(w)) |
55 |
|
{ |
56 |
|
case IDC_CHOICE_DISC: |
57 |
< |
*choice = disc; |
57 |
> |
data->choice = disc; |
58 |
|
if (debug) cerr << "choice = disc\n"; |
59 |
|
EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE); |
60 |
|
EnableWindow(GetDlgItem(dialog, IDOK), TRUE); |
61 |
|
break; |
62 |
|
case IDC_CHOICE_SCAN: |
63 |
< |
*choice = scan; |
63 |
> |
data->choice = scan; |
64 |
|
if (debug) cerr << "choice = scan\n"; |
65 |
|
EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE); |
66 |
|
EnableWindow(GetDlgItem(dialog, IDOK), TRUE); |
67 |
|
break; |
68 |
|
case IDC_CHOICE_ALWAYS: |
69 |
< |
*shortcut = !*shortcut; |
70 |
< |
if (debug) cerr << "shortcut = " << *shortcut << "\n"; |
69 |
> |
data->shortcut = !data->shortcut; |
70 |
> |
if (debug) cerr << "shortcut = " << data->shortcut << "\n"; |
71 |
|
break; |
72 |
|
case IDCANCEL: |
73 |
< |
*choice = none; |
73 |
> |
data->choice = none; |
74 |
|
case IDOK: |
73 |
– |
windows.erase(dialog); |
75 |
|
EndDialog(dialog, w); |
76 |
|
return TRUE; |
77 |
|
default: |
78 |
|
break; |
79 |
|
} |
80 |
|
break; |
81 |
+ |
case WM_DESTROY: |
82 |
+ |
windows.erase(dialog); |
83 |
+ |
break; |
84 |
|
} |
85 |
|
|
86 |
|
return FALSE; |
87 |
|
} |
88 |
|
|
85 |
– |
unsigned Chooser::count = 0; |
86 |
– |
map<unsigned, Chooser*> Chooser::choosers; |
87 |
– |
map<HWND, Chooser*> Chooser::windows; |
88 |
– |
|
89 |
|
void Chooser::desktop(void) |
90 |
|
{ |
91 |
|
if (!shortcut || choice == none) return; |
92 |
|
|
93 |
|
IShellLink* link; |
94 |
|
|
95 |
– |
CoInitialize(NULL); |
95 |
|
CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, |
96 |
|
IID_IShellLink, (LPVOID*)(&link)); |
97 |
|
|
131 |
|
link->Release(); |
132 |
|
|
133 |
|
delete [] desktop; |
135 |
– |
|
136 |
– |
CoUninitialize(); |
134 |
|
} |