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>
13 #include <afs/fs_utils.h>
16 #include "afs_config.h"
18 #include "tab_general.h"
19 #include "tab_prefs.h"
20 #include "tab_hosts.h"
21 #include "tab_drives.h"
22 #include "tab_advanced.h"
25 * DEFINITIONS ________________________________________________________________
31 * VARIABLES __________________________________________________________________
39 * PROTOTYPES _________________________________________________________________
47 * ROUTINES ___________________________________________________________________
51 int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pCmdLine, int nCmdShow)
53 TaLocale_LoadCorrespondingModule (hInst);
55 // Initialize winsock etc
58 WSAStartup (0x0101, &Data);
61 RegisterCheckListClass();
62 RegisterFastListClass();
63 RegisterSockAddrClass();
64 RegisterSpinnerClass();
65 fs_utils_InitMountRoot();
67 // Initialize our global variables and window classes
69 memset (&g, 0x00, sizeof(g));
70 g.fIsWinNT = IsWindowsNT();
71 g.fIsAdmin = IsAdmin();
73 // Check our command-line options
75 while (pCmdLine && (*pCmdLine=='/' || *pCmdLine=='-'))
77 switch (*(++pCmdLine))
85 while (*pCmdLine == ' ')
89 // Select an appropriate help file
92 lstrcpy (g.szHelpFile, TEXT("afs-cc.hlp>dialog"));
94 lstrcpy (g.szHelpFile, TEXT("afs-nt.hlp>dialog"));
96 lstrcpy (g.szHelpFile, TEXT("afs-light.hlp>dialog"));
98 // Our main window is actually a tabbed dialog.
100 if ((g.psh = PropSheet_Create (((g.fIsCCenter) ? IDS_TITLE_CCENTER : (g.fIsWinNT) ? IDS_TITLE_NT : IDS_TITLE_95), FALSE, NULL)) == NULL)
103 g.psh->sh.dwFlags |= PSH_NOAPPLYNOW; // Remove the Apply button
104 g.psh->sh.dwFlags |= PSH_HASHELP; // Add a Help button instead
108 PropSheet_AddTab (g.psh, 0, IDD_HOSTS_CCENTER, (DLGPROC)HostsTab_DlgProc, 0, TRUE);
112 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_GENERAL_NT : IDD_GENERAL_95), (DLGPROC)GeneralTab_DlgProc, 0, TRUE);
114 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_DRIVES_NT : IDD_DRIVES_95), (DLGPROC)DrivesTab_DlgProc, 0, TRUE);
117 PropSheet_AddTab (g.psh, 0, IDD_PREFS_NT, (DLGPROC)PrefsTab_DlgProc, 0, TRUE);
119 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_HOSTS_NT : IDD_HOSTS_95), (DLGPROC)HostsTab_DlgProc, 0, TRUE);
122 PropSheet_AddTab (g.psh, 0, IDD_ADVANCED_NT, (DLGPROC)AdvancedTab_DlgProc, 0, TRUE);
125 PropSheet_ShowModal (g.psh);
131 void Main_OnInitDialog (HWND hMain)
135 // Center the window in the display
138 GetWindowRect (g.hMain, &rWindow);
141 SystemParametersInfo (SPI_GETWORKAREA, 0, &rDesktop, 0);
143 SetWindowPos (g.hMain, NULL,
144 rDesktop.left + ((rDesktop.right - rDesktop.left) - (rWindow.right - rWindow.left)) / 2,
145 rDesktop.top + ((rDesktop.bottom - rDesktop.top) - (rWindow.bottom - rWindow.top)) / 2,
146 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
148 // Remove the Context Help [?] thing from the title bar
150 DWORD dwStyle = GetWindowLong (g.hMain, GWL_STYLE);
151 dwStyle &= ~DS_CONTEXTHELP;
152 SetWindowLong (g.hMain, GWL_STYLE, dwStyle);
154 dwStyle = GetWindowLong (hMain, GWL_EXSTYLE);
155 dwStyle &= ~WS_EX_CONTEXTHELP;
156 SetWindowLong (g.hMain, GWL_EXSTYLE, dwStyle);
160 void Main_RefreshAllTabs (void)
162 for (size_t ii = 0; ii < g.psh->cTabs; ++ii)
164 if (!g.psh->aTabs[ii].dlgproc)
166 if (!IsWindow (g.psh->aTabs[ii].hDlg))
169 CallWindowProc ((WNDPROC)(g.psh->aTabs[ii].dlgproc), g.psh->aTabs[ii].hDlg, WM_COMMAND, IDC_REFRESH, 0);
176 if (IsWindow (g.hMain))
178 DestroyWindow (g.hMain);
184 LPCTSTR GetCautionTitle (void)
186 static TCHAR szTitle[ cchRESOURCE ] = TEXT("");
188 GetString (szTitle, (g.fIsCCenter) ? IDS_TITLE_CAUTION_CCENTER : (g.fIsWinNT) ? IDS_TITLE_CAUTION_NT : IDS_TITLE_CAUTION_95);
193 LPCTSTR GetErrorTitle (void)
195 static TCHAR szTitle[ cchRESOURCE ] = TEXT("");
197 GetString (szTitle, (g.fIsCCenter) ? IDS_TITLE_ERROR_CCENTER : (g.fIsWinNT) ? IDS_TITLE_ERROR_NT : IDS_TITLE_ERROR_95);