ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/VTBFileUtil2/Chooser.cxx
(Generate patch)

Comparing trunk/VTBFileUtil2/Chooser.cxx (file contents):
Revision 264 by douglas, 2003-08-16T17:43:49-07:00 vs.
Revision 269 by douglas, 2003-08-19T01:19:24-07:00

# Line 2 | Line 2
2   //
3   // Douglas Thrift
4   //
5 < // $Id: Chooser.cxx,v 1.2 2003/08/17 00:43:49 douglas Exp $
5 > // $Id: Chooser.cxx,v 1.7 2003/08/19 08:19:24 douglas Exp $
6  
7   #include "Chooser.h"
8  
9 < struct
9 > Chooser::Chooser()
10   {
11 <        bool* shortcut;
12 <        Mode* choice;
11 >        shortcut = false;
12 >        choice = none;
13 >        number = count++;
14 >        choosers.insert(pair<unsigned, Chooser*>(number, this));
15   }
14 cheese;
16  
17 < Mode Chooser::choose(HWND parent)
17 > Chooser::~Chooser()
18   {
19 <        cheese.shortcut = &shortcut;
20 <        cheese.choice = &choice;
19 >        choosers.erase(number);
20 > }
21  
22 <        DialogBox(gui.instance, MAKEINTRESOURCE(IDD_CHOICE), parent, smersh);
22 > Mode Chooser::choose(HWND parent)
23 > {
24 >        DialogBoxParam(gui.instance, MAKEINTRESOURCE(IDD_CHOICE), parent,
25 >                Chooser::window, number);
26  
27          desktop();
28  
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;
40 +
41 +        switch (msg)
42 +        {
43 +        case WM_INITDIALOG:
44 +                center(dialog);
45 +                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
46 +                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
47 +                {
48 +                        map<unsigned, Chooser*>::iterator itor = choosers.find(l);
49 +                        
50 +                        windows.insert(pair<HWND, Chooser*>(dialog, itor->second));
51 +                }
52 +                break;
53 +        case WM_COMMAND:
54 +                switch (LOWORD(w))
55 +                {
56 +                case IDC_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 +                        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 +                        data->shortcut = !data->shortcut;
70 +                        if (debug) cerr << "shortcut = " << data->shortcut << "\n";
71 +                        break;
72 +                case IDCANCEL:
73 +                        data->choice = none;
74 +                case IDOK:
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 +
89   void Chooser::desktop(void)
90   {
91          if (!shortcut || choice == none) return;
92  
93          IShellLink* link;
94  
34        CoInitialize(NULL);
95          CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
96                  IID_IShellLink, (LPVOID*)(&link));
97  
# Line 70 | Line 130 | void Chooser::desktop(void)
130          file->Release();
131          link->Release();
132  
133 <        CoUninitialize();
74 < }
75 <
76 < INT_PTR CALLBACK smersh(HWND dialog, UINT msg, WPARAM w, LPARAM l)
77 < {
78 <        switch (msg)
79 <        {
80 <        case WM_INITDIALOG:
81 <                center(dialog);
82 <                SendMessage(dialog, WM_SETICON, ICON_BIG, LPARAM(gui.icon));
83 <                SendMessage(dialog, WM_SETTEXT, 0, LPARAM(programName.c_str()));
84 <                break;
85 <        case WM_COMMAND:
86 <                switch (LOWORD(w))
87 <                {
88 <                case IDC_CHOICE_DISC:
89 <                        *cheese.choice = disc;
90 <                        if (debug) cerr << "choice = disc\n";
91 <                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
92 <                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
93 <                        break;
94 <                case IDC_CHOICE_SCAN:
95 <                        *cheese.choice = scan;
96 <                        if (debug) cerr << "choice = scan\n";
97 <                        EnableWindow(GetDlgItem(dialog, IDC_CHOICE_ALWAYS), TRUE);
98 <                        EnableWindow(GetDlgItem(dialog, IDOK), TRUE);
99 <                        break;
100 <                case IDC_CHOICE_ALWAYS:
101 <                        *cheese.shortcut = !*cheese.shortcut;
102 <                        if (debug) cerr << "shortcut = " << *cheese.shortcut << "\n";
103 <                        break;
104 <                case IDCANCEL:
105 <                        *cheese.choice = none;
106 <                case IDOK:
107 <                        EndDialog(dialog, w);
108 <                        return TRUE;
109 <                default:
110 <                        break;
111 <                }
112 <                break;
113 <        }
114 <
115 <        return FALSE;
133 >        delete [] desktop;
134   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines