KFW Network Identity Manager (Beta 2)
[krb5.git] / src / windows / identity / ui / aboutwnd.c
1 /*\r
2  * Copyright (c) 2005 Massachusetts Institute of Technology\r
3  *\r
4  * Permission is hereby granted, free of charge, to any person\r
5  * obtaining a copy of this software and associated documentation\r
6  * files (the "Software"), to deal in the Software without\r
7  * restriction, including without limitation the rights to use, copy,\r
8  * modify, merge, publish, distribute, sublicense, and/or sell copies\r
9  * of the Software, and to permit persons to whom the Software is\r
10  * furnished to do so, subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be\r
13  * included in all copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
22  * SOFTWARE.\r
23  */\r
24 \r
25 /* $Id$ */\r
26 \r
27 #include<khmapp.h>\r
28 #include<netidmgr_intver.h>\r
29 #include<tlhelp32.h>\r
30 \r
31 #if DEBUG\r
32 #include<assert.h>\r
33 #endif\r
34 \r
35 INT_PTR CALLBACK\r
36 about_dlg_proc(HWND hwnd,\r
37                UINT uMsg,\r
38                WPARAM wParam,\r
39                LPARAM lParam) {\r
40 \r
41     switch(uMsg) {\r
42     case WM_INITDIALOG:\r
43         {\r
44             HANDLE hsnap;\r
45             HWND hw;\r
46 \r
47             SetDlgItemText(hwnd, IDC_PRODUCT,\r
48                            TEXT(KH_VERSTR_PRODUCT_1033));\r
49             SetDlgItemText(hwnd, IDC_COPYRIGHT,\r
50                            TEXT(KH_VERSTR_COPYRIGHT_1033));\r
51             SetDlgItemText(hwnd, IDC_BUILDINFO,\r
52                            TEXT(KH_VERSTR_BUILDINFO_1033));\r
53 \r
54             hsnap = \r
55                 CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,\r
56                                          0);\r
57 \r
58             if (hsnap != INVALID_HANDLE_VALUE) {\r
59                 LVCOLUMN lvc;\r
60                 MODULEENTRY32 mod;\r
61                 RECT r;\r
62 \r
63                 hw = GetDlgItem(hwnd, IDC_MODULES);\r
64 #ifdef DEBUG\r
65                 assert(hw != NULL);\r
66 #endif\r
67 \r
68                 GetWindowRect(hw, &r);\r
69                 OffsetRect(&r, -r.left, -r.top);\r
70 \r
71                 ZeroMemory(&lvc, sizeof(lvc));\r
72                 lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
73 \r
74                 lvc.pszText = L"Name";\r
75                 lvc.cx = r.right / 4;\r
76 \r
77                 ListView_InsertColumn(hw, 0, &lvc);\r
78 \r
79                 lvc.pszText = L"Path";\r
80                 lvc.cx = (r.right * 3) / 4;\r
81                 ListView_InsertColumn(hw, 1, &lvc);\r
82 \r
83                 ZeroMemory(&mod, sizeof(mod));\r
84                 mod.dwSize = sizeof(mod);\r
85 \r
86                 /* done with columns, now for the actual data */\r
87                 if (!Module32First(hsnap, &mod))\r
88                     goto _done_with_modules;\r
89 \r
90                 do {\r
91 \r
92                     LVITEM lvi;\r
93                     int idx;\r
94 \r
95                     ZeroMemory(&lvi, sizeof(lvi));\r
96 \r
97                     lvi.mask = LVIF_TEXT;\r
98                     lvi.pszText = mod.szModule;\r
99                     idx = ListView_InsertItem(hw, &lvi);\r
100 \r
101                     lvi.mask = LVIF_TEXT;\r
102                     lvi.iItem = idx;\r
103                     lvi.iSubItem = 1;\r
104                     lvi.pszText = mod.szExePath;\r
105                     ListView_SetItem(hw, &lvi);\r
106 \r
107                     ZeroMemory(&mod, sizeof(mod));\r
108                     mod.dwSize = sizeof(mod);\r
109                 } while(Module32Next(hsnap, &mod));\r
110 \r
111 #if (_WIN32_WINNT >= 0x501)\r
112                 /* we are also setting the report style when creating\r
113                    the control.  this is actually optional. */\r
114                 ListView_SetView(hw, LV_VIEW_DETAILS);\r
115 #endif\r
116 \r
117             _done_with_modules:\r
118                 CloseHandle(hsnap);\r
119             }\r
120 \r
121             khm_add_dialog(hwnd);\r
122             khm_enter_modal(hwnd);\r
123         }\r
124         return FALSE;\r
125 \r
126     case WM_DESTROY:\r
127         khm_leave_modal();\r
128         khm_del_dialog(hwnd);\r
129         return TRUE;\r
130 \r
131     case WM_COMMAND:\r
132         if (wParam == MAKEWPARAM(IDOK, BN_CLICKED))\r
133             DestroyWindow(hwnd);\r
134         return TRUE;\r
135     }\r
136 \r
137     return FALSE;\r
138 }\r
139 \r
140 void\r
141 khm_create_about_window(void) {\r
142     HWND hwnd;\r
143     hwnd = CreateDialog(khm_hInstance,\r
144                         MAKEINTRESOURCE(IDD_ABOUT),\r
145                         khm_hwnd_main,\r
146                         about_dlg_proc);\r
147 \r
148     ShowWindow(hwnd, SW_SHOW);\r
149     /* no need to keep track of the hwnd, since we add it to the\r
150        dialog chain in the dialog procedure */\r
151 }\r