Make reindent
[krb5.git] / src / windows / identity / ui / aboutwnd.c
index 4f5d38ef48d7010a7a3ee49c90f6bbb9d79e4868..a9efcfbffb97c56d10329bf414c81eb7fdda843d 100644 (file)
-/*\r
- * Copyright (c) 2005 Massachusetts Institute of Technology\r
- *\r
- * Permission is hereby granted, free of charge, to any person\r
- * obtaining a copy of this software and associated documentation\r
- * files (the "Software"), to deal in the Software without\r
- * restriction, including without limitation the rights to use, copy,\r
- * modify, merge, publish, distribute, sublicense, and/or sell copies\r
- * of the Software, and to permit persons to whom the Software is\r
- * furnished to do so, subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be\r
- * included in all copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
- * SOFTWARE.\r
- */\r
-\r
-/* $Id$ */\r
-\r
-#include<khmapp.h>\r
-#include<netidmgr_intver.h>\r
-#include<tlhelp32.h>\r
-\r
-#if DEBUG\r
-#include<assert.h>\r
-#endif\r
-\r
-INT_PTR CALLBACK\r
-about_dlg_proc(HWND hwnd,\r
-               UINT uMsg,\r
-               WPARAM wParam,\r
-               LPARAM lParam) {\r
-\r
-    switch(uMsg) {\r
-    case WM_INITDIALOG:\r
-        {\r
-            HANDLE hsnap;\r
-            HWND hw;\r
-\r
-            SetDlgItemText(hwnd, IDC_PRODUCT,\r
-                           TEXT(KH_VERSTR_PRODUCT_1033));\r
-            SetDlgItemText(hwnd, IDC_COPYRIGHT,\r
-                           TEXT(KH_VERSTR_COPYRIGHT_1033));\r
-            SetDlgItemText(hwnd, IDC_BUILDINFO,\r
-                           TEXT(KH_VERSTR_BUILDINFO_1033));\r
-\r
-            hsnap = \r
-                CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,\r
-                                         0);\r
-\r
-            if (hsnap != INVALID_HANDLE_VALUE) {\r
-                LVCOLUMN lvc;\r
-                MODULEENTRY32 mod;\r
-                RECT r;\r
-\r
-                hw = GetDlgItem(hwnd, IDC_MODULES);\r
-#ifdef DEBUG\r
-                assert(hw != NULL);\r
-#endif\r
-\r
-                GetWindowRect(hw, &r);\r
-                OffsetRect(&r, -r.left, -r.top);\r
-\r
-                ZeroMemory(&lvc, sizeof(lvc));\r
-                lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
-\r
-                lvc.pszText = L"Name";\r
-                lvc.cx = r.right / 4;\r
-\r
-                ListView_InsertColumn(hw, 0, &lvc);\r
-\r
-                lvc.pszText = L"Path";\r
-                lvc.cx = (r.right * 3) / 4;\r
-                ListView_InsertColumn(hw, 1, &lvc);\r
-\r
-                ZeroMemory(&mod, sizeof(mod));\r
-                mod.dwSize = sizeof(mod);\r
-\r
-                /* done with columns, now for the actual data */\r
-                if (!Module32First(hsnap, &mod))\r
-                    goto _done_with_modules;\r
-\r
-                do {\r
-\r
-                    LVITEM lvi;\r
-                    int idx;\r
-\r
-                    ZeroMemory(&lvi, sizeof(lvi));\r
-\r
-                    lvi.mask = LVIF_TEXT;\r
-                    lvi.pszText = mod.szModule;\r
-                    idx = ListView_InsertItem(hw, &lvi);\r
-\r
-                    lvi.mask = LVIF_TEXT;\r
-                    lvi.iItem = idx;\r
-                    lvi.iSubItem = 1;\r
-                    lvi.pszText = mod.szExePath;\r
-                    ListView_SetItem(hw, &lvi);\r
-\r
-                    ZeroMemory(&mod, sizeof(mod));\r
-                    mod.dwSize = sizeof(mod);\r
-                } while(Module32Next(hsnap, &mod));\r
-\r
-#if (_WIN32_WINNT >= 0x501)\r
-                /* we are also setting the report style when creating\r
-                   the control.  this is actually optional. */\r
-                ListView_SetView(hw, LV_VIEW_DETAILS);\r
-#endif\r
-\r
-            _done_with_modules:\r
-                CloseHandle(hsnap);\r
-            }\r
-\r
-            khm_add_dialog(hwnd);\r
-            khm_enter_modal(hwnd);\r
-        }\r
-        return FALSE;\r
-\r
-    case WM_DESTROY:\r
-        khm_leave_modal();\r
-        khm_del_dialog(hwnd);\r
-        return TRUE;\r
-\r
-    case WM_COMMAND:\r
-        if (wParam == MAKEWPARAM(IDOK, BN_CLICKED))\r
-            DestroyWindow(hwnd);\r
-        return TRUE;\r
-    }\r
-\r
-    return FALSE;\r
-}\r
-\r
-void\r
-khm_create_about_window(void) {\r
-    HWND hwnd;\r
-    hwnd = CreateDialog(khm_hInstance,\r
-                        MAKEINTRESOURCE(IDD_ABOUT),\r
-                        khm_hwnd_main,\r
-                        about_dlg_proc);\r
-\r
-    ShowWindow(hwnd, SW_SHOW);\r
-    /* no need to keep track of the hwnd, since we add it to the\r
-       dialog chain in the dialog procedure */\r
-}\r
+/*
+ * Copyright (c) 2005 Massachusetts Institute of Technology
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* $Id$ */
+
+#include<khmapp.h>
+#include<netidmgr_intver.h>
+#include<tlhelp32.h>
+
+#if DEBUG
+#include<assert.h>
+#endif
+
+INT_PTR CALLBACK
+about_dlg_proc(HWND hwnd,
+               UINT uMsg,
+               WPARAM wParam,
+               LPARAM lParam) {
+
+    switch(uMsg) {
+    case WM_INITDIALOG:
+        {
+            HANDLE hsnap;
+            HWND hw;
+
+            SetDlgItemText(hwnd, IDC_PRODUCT,
+                           TEXT(KH_VERSTR_PRODUCT_1033));
+            /* retain the original copyright strings */
+#ifdef OVERRIDE_COPYRIGHT
+            SetDlgItemText(hwnd, IDC_COPYRIGHT,
+                           TEXT(KH_VERSTR_COPYRIGHT_1033));
+#endif
+            SetDlgItemText(hwnd, IDC_BUILDINFO,
+                           TEXT(KH_VERSTR_BUILDINFO_1033));
+
+            hsnap =
+                CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,
+                                         0);
+
+            if (hsnap != INVALID_HANDLE_VALUE) {
+                LVCOLUMN lvc;
+                MODULEENTRY32 mod;
+                RECT r;
+
+                hw = GetDlgItem(hwnd, IDC_MODULES);
+#ifdef DEBUG
+                assert(hw != NULL);
+#endif
+
+                GetWindowRect(hw, &r);
+                OffsetRect(&r, -r.left, -r.top);
+
+                ZeroMemory(&lvc, sizeof(lvc));
+                lvc.mask = LVCF_TEXT | LVCF_WIDTH;
+
+                lvc.pszText = L"Name";
+                lvc.cx = r.right / 4;
+
+                ListView_InsertColumn(hw, 0, &lvc);
+
+                lvc.pszText = L"Path";
+                lvc.cx = (r.right * 3) / 4;
+                ListView_InsertColumn(hw, 1, &lvc);
+
+                ZeroMemory(&mod, sizeof(mod));
+                mod.dwSize = sizeof(mod);
+
+                /* done with columns, now for the actual data */
+                if (!Module32First(hsnap, &mod))
+                    goto _done_with_modules;
+
+                do {
+
+                    LVITEM lvi;
+                    int idx;
+
+                    ZeroMemory(&lvi, sizeof(lvi));
+
+                    lvi.mask = LVIF_TEXT;
+                    lvi.pszText = mod.szModule;
+                    idx = ListView_InsertItem(hw, &lvi);
+
+                    lvi.mask = LVIF_TEXT;
+                    lvi.iItem = idx;
+                    lvi.iSubItem = 1;
+                    lvi.pszText = mod.szExePath;
+                    ListView_SetItem(hw, &lvi);
+
+                    ZeroMemory(&mod, sizeof(mod));
+                    mod.dwSize = sizeof(mod);
+                } while(Module32Next(hsnap, &mod));
+
+            _done_with_modules:
+                CloseHandle(hsnap);
+            }
+
+            khm_add_dialog(hwnd);
+            khm_enter_modal(hwnd);
+        }
+        return FALSE;
+
+    case WM_DESTROY:
+        khm_del_dialog(hwnd);
+        return TRUE;
+
+    case WM_CLOSE:
+        khm_leave_modal();
+        DestroyWindow(hwnd);
+        return TRUE;
+
+    case WM_COMMAND:
+        if (wParam == MAKEWPARAM(IDOK, BN_CLICKED)) {
+            khm_leave_modal();
+            DestroyWindow(hwnd);
+        }
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+void
+khm_create_about_window(void) {
+    HWND hwnd;
+    hwnd = CreateDialog(khm_hInstance,
+                        MAKEINTRESOURCE(IDD_ABOUT),
+                        khm_hwnd_main,
+                        about_dlg_proc);
+
+    ShowWindow(hwnd, SW_SHOW);
+    /* no need to keep track of the hwnd, since we add it to the
+       dialog chain in the dialog procedure */
+}