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
11 #include <afs/param.h>
17 * INCLUDES ___________________________________________________________________
20 #include "afscfg.h" // Main header for this application
22 #include "admin_info_dlg.h"
26 * DEFINITIONS _________________________________________________________________
29 static HWND hDlg = 0; // HWND for this page's dialog
30 static GET_ADMIN_INFO_OPTIONS eOptions; // Are we asking user for another server?
34 * PROTOTYPES _________________________________________________________________
37 static void OnInitDialog(HWND hwndDlg);
38 static void CheckEnableButtons();
39 static void SaveDlgInfo();
40 static void ShowPageInfo();
42 BOOL CALLBACK AdminInfoDlgProc(HWND hRHS, UINT msg, WPARAM wp, LPARAM lp);
46 * EXPORTED FUNCTIONS _________________________________________________________
49 BOOL GetAdminInfo(HWND hParent, GET_ADMIN_INFO_OPTIONS options)
53 int nResult = ModalDialog(IDD_ADMIN_INFO, hParent, (DLGPROC)AdminInfoDlgProc);
55 return (nResult == IDOK);
60 * Dialog Proc _________________________________________________________________
63 BOOL CALLBACK AdminInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wp, LPARAM lp)
65 if (AfsAppLib_HandleHelp(IDD_ADMIN_INFO, hwndDlg, msg, wp, lp))
70 OnInitDialog(hwndDlg);
79 if (HIWORD(wp) == EN_CHANGE)
84 EndDialog(hDlg, IDCANCEL);
90 EndDialog(hDlg, IDOK);
101 * STATIC FUNCTIONS _________________________________________________________________
106 * Event Handler Functions _________________________________________________________________
109 static void OnInitDialog(HWND hwndDlg)
111 static int nOffset = 0;
115 // Hide the additional server stuff if we don't need it
116 if (eOptions == GAIO_LOGIN_ONLY) {
117 HideAndDisable(hDlg, IDC_HOSTNAME_FRAME);
118 HideAndDisable(hDlg, IDC_HOSTNAME_PROMPT);
119 HideAndDisable(hDlg, IDC_HOSTNAME_LABEL);
120 HideAndDisable(hDlg, IDC_HOSTNAME);
123 // Get dimensions of the frame containing the things we will hide or show
125 GetWindowRect(GetDlgItem(hDlg, IDC_HOSTNAME_FRAME), &rectFrame);
127 // Get original position of the buttons
129 GetWindowRect(GetDlgItem(hDlg, IDCANCEL), &rectButton);
131 // Figure out how far the buttons will have to move to be at the top
133 nOffset = rectButton.top - rectFrame.top;
137 MoveWnd(hDlg, IDOK, 0, -nOffset);
138 MoveWnd(hDlg, IDCANCEL, 0, -nOffset);
139 MoveWnd(hDlg, IDHELP, 0, -nOffset);
143 GetWindowRect(hDlg, &rectDlg);
144 MoveWindow(hDlg, rectDlg.left, rectDlg.top, rectDlg.right - rectDlg.left + 1, rectDlg.bottom - rectDlg.top - nOffset, TRUE);
152 * Utility Functions _________________________________________________________________
155 static void CheckEnableButtons()
157 BOOL bDisable = FALSE;
159 TCHAR szDummy[cchRESOURCE];
161 bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_NAME, szDummy)) == 0;
162 bDisable |= lstrlen(GetWndText(hDlg, IDC_ADMIN_PW, szDummy)) == 0;
164 SetEnable(hDlg, IDOK, (ENABLE_STATE)!bDisable);
167 static void SaveDlgInfo()
169 TCHAR szText[cchRESOURCE];
171 lstrncpy(g_CfgData.szAdminName, GetWndText(hDlg, IDC_ADMIN_NAME, szText), MAX_ADMIN_NAME_LEN);
172 lstrncpy(g_CfgData.szAdminPW, GetWndText(hDlg, IDC_ADMIN_PW, szText), MAX_ADMIN_PW_LEN);
174 if (eOptions == GAIO_GET_SCS)
175 lstrncpy(g_CfgData.szSysControlMachine, GetWndText(hDlg, IDC_HOSTNAME, szText), MAX_MACHINE_NAME_LEN);
178 static void ShowPageInfo()
180 SetWndText(hDlg, IDC_ADMIN_NAME, g_CfgData.szAdminName);
181 SetWndText(hDlg, IDC_ADMIN_PW, g_CfgData.szAdminPW);
183 if (eOptions == GAIO_GET_SCS)
184 SetWndText(hDlg, IDC_HOSTNAME, g_CfgData.szSysControlMachine);