KFW 3.1 Beta 2 NetIDMgr Changes
[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             /* retain the original copyright strings */\r
50 #ifdef OVERRIDE_COPYRIGHT\r
51             SetDlgItemText(hwnd, IDC_COPYRIGHT,\r
52                            TEXT(KH_VERSTR_COPYRIGHT_1033));\r
53 #endif\r
54             SetDlgItemText(hwnd, IDC_BUILDINFO,\r
55                            TEXT(KH_VERSTR_BUILDINFO_1033));\r
56 \r
57             hsnap = \r
58                 CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,\r
59                                          0);\r
60 \r
61             if (hsnap != INVALID_HANDLE_VALUE) {\r
62                 LVCOLUMN lvc;\r
63                 MODULEENTRY32 mod;\r
64                 RECT r;\r
65 \r
66                 hw = GetDlgItem(hwnd, IDC_MODULES);\r
67 #ifdef DEBUG\r
68                 assert(hw != NULL);\r
69 #endif\r
70 \r
71                 GetWindowRect(hw, &r);\r
72                 OffsetRect(&r, -r.left, -r.top);\r
73 \r
74                 ZeroMemory(&lvc, sizeof(lvc));\r
75                 lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
76 \r
77                 lvc.pszText = L"Name";\r
78                 lvc.cx = r.right / 4;\r
79 \r
80                 ListView_InsertColumn(hw, 0, &lvc);\r
81 \r
82                 lvc.pszText = L"Path";\r
83                 lvc.cx = (r.right * 3) / 4;\r
84                 ListView_InsertColumn(hw, 1, &lvc);\r
85 \r
86                 ZeroMemory(&mod, sizeof(mod));\r
87                 mod.dwSize = sizeof(mod);\r
88 \r
89                 /* done with columns, now for the actual data */\r
90                 if (!Module32First(hsnap, &mod))\r
91                     goto _done_with_modules;\r
92 \r
93                 do {\r
94 \r
95                     LVITEM lvi;\r
96                     int idx;\r
97 \r
98                     ZeroMemory(&lvi, sizeof(lvi));\r
99 \r
100                     lvi.mask = LVIF_TEXT;\r
101                     lvi.pszText = mod.szModule;\r
102                     idx = ListView_InsertItem(hw, &lvi);\r
103 \r
104                     lvi.mask = LVIF_TEXT;\r
105                     lvi.iItem = idx;\r
106                     lvi.iSubItem = 1;\r
107                     lvi.pszText = mod.szExePath;\r
108                     ListView_SetItem(hw, &lvi);\r
109 \r
110                     ZeroMemory(&mod, sizeof(mod));\r
111                     mod.dwSize = sizeof(mod);\r
112                 } while(Module32Next(hsnap, &mod));\r
113 \r
114             _done_with_modules:\r
115                 CloseHandle(hsnap);\r
116             }\r
117 \r
118             khm_add_dialog(hwnd);\r
119             khm_enter_modal(hwnd);\r
120         }\r
121         return FALSE;\r
122 \r
123     case WM_DESTROY:\r
124         khm_del_dialog(hwnd);\r
125         return TRUE;\r
126 \r
127     case WM_COMMAND:\r
128         if (wParam == MAKEWPARAM(IDOK, BN_CLICKED)) {\r
129             khm_leave_modal();\r
130             DestroyWindow(hwnd);\r
131         }\r
132         return TRUE;\r
133     }\r
134 \r
135     return FALSE;\r
136 }\r
137 \r
138 void\r
139 khm_create_about_window(void) {\r
140     HWND hwnd;\r
141     hwnd = CreateDialog(khm_hInstance,\r
142                         MAKEINTRESOURCE(IDD_ABOUT),\r
143                         khm_hwnd_main,\r
144                         about_dlg_proc);\r
145 \r
146     ShowWindow(hwnd, SW_SHOW);\r
147     /* no need to keep track of the hwnd, since we add it to the\r
148        dialog chain in the dialog procedure */\r
149 }\r