2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
14 #include <afsconfig.h>
15 #include <afs/param.h>
22 * INCLUDES ___________________________________________________________________
25 #include "afscfg.h" // Main header for this application
27 #include "admin_info_dlg.h"
31 * DEFINITIONS _________________________________________________________________
34 static HWND hDlg = 0; // HWND for this page's dialog
35 static GET_ADMIN_INFO_OPTIONS eOptions; // Are we asking user for another server?
39 * PROTOTYPES _________________________________________________________________
42 static void OnInitDialog(HWND hwndDlg);
43 static void CheckEnableButtons();
44 static void SaveDlgInfo();
45 static void ShowPageInfo();
47 BOOL CALLBACK AdminInfoDlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp);
51 * EXPORTED FUNCTIONS _________________________________________________________
54 BOOL GetAdminInfo(HWND hParent, GET_ADMIN_INFO_OPTIONS options)
58 int nResult = ModalDialog(IDD_ADMIN_INFO, hParent, (DLGPROC)AdminInfoDlgProc);
60 return (nResult == IDOK);
65 * Dialog Proc _________________________________________________________________
68 BOOL CALLBACK AdminInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
70 if (AfsAppLib_HandleHelp(IDD_ADMIN_INFO, hwndDlg, msg, wp, lp))
75 OnInitDialog(hwndDlg);
84 if (HIWORD(wp) == EN_CHANGE)
89 EndDialog(hDlg, IDCANCEL);
94 EndDialog(hDlg, IDOK);
105 * STATIC FUNCTIONS _________________________________________________________________
110 * Event Handler Functions _________________________________________________________________
113 static void OnInitDialog(HWND hwndDlg)
115 static int nOffset = 0;
119 // Hide the additional server stuff if we don't need it
120 if (eOptions == GAIO_LOGIN_ONLY) {
121 HideAndDisable(hDlg, IDC_HOSTNAME_FRAME);
122 HideAndDisable(hDlg, IDC_HOSTNAME_PROMPT);
123 HideAndDisable(hDlg, IDC_HOSTNAME_LABEL);
124 HideAndDisable(hDlg, IDC_HOSTNAME);
127 // Get dimensions of the frame containing the things we will hide or show
129 GetWindowRect(GetDlgItem(hDlg, IDC_HOSTNAME_FRAME), &rectFrame);
131 // Get original position of the buttons
133 GetWindowRect(GetDlgItem(hDlg, IDCANCEL), &rectButton);
135 // Figure out how far the buttons will have to move to be at the top
137 nOffset = rectButton.top - rectFrame.top;
141 MoveWnd(hDlg, IDOK, 0, -nOffset);
142 MoveWnd(hDlg, IDCANCEL, 0, -nOffset);
143 MoveWnd(hDlg, IDHELP, 0, -nOffset);
147 GetWindowRect(hDlg, &rectDlg);
148 MoveWindow(hDlg, rectDlg.left, rectDlg.top, rectDlg.right - rectDlg.left + 1, rectDlg.bottom - rectDlg.top - nOffset, TRUE);
155 * Utility Functions _________________________________________________________________
158 static void CheckEnableButtons()
160 BOOL bDisable = FALSE;
162 TCHAR szDummy[cchRESOURCE];
164 bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_NAME, szDummy)) == 0;
165 bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_PW, szDummy)) == 0;
167 SetEnable(hDlg, IDOK, (ENABLE_STATE)!bDisable);
170 static void SaveDlgInfo()
172 TCHAR szText[cchRESOURCE];
174 lstrncpy(g_CfgData.szAdminName, GetWndText(hDlg, IDC_ADMIN_NAME, szText), MAX_ADMIN_NAME_LEN);
175 lstrncpy(g_CfgData.szAdminPW, GetWndText(hDlg, IDC_ADMIN_PW, szText), MAX_ADMIN_PW_LEN);
177 if (eOptions == GAIO_GET_SCS)
178 lstrncpy(g_CfgData.szSysControlMachine, GetWndText(hDlg, IDC_HOSTNAME, szText), MAX_MACHINE_NAME_LEN);
181 static void ShowPageInfo()
183 SetWndText(hDlg, IDC_ADMIN_NAME, g_CfgData.szAdminName);
184 SetWndText(hDlg, IDC_ADMIN_PW, g_CfgData.szAdminPW);
186 if (eOptions == GAIO_GET_SCS)
187 SetWndText(hDlg, IDC_HOSTNAME, g_CfgData.szSysControlMachine);