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 __________________________________________________________________
38 * ROUTINES ___________________________________________________________________
42 extern "C" int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR pCmdLine, int nCmdShow)
44 TaLocale_LoadCorrespondingModule (hInst);
46 // Initialize winsock etc
49 WSAStartup (0x0101, &Data);
52 RegisterCheckListClass();
53 RegisterFastListClass();
54 RegisterSockAddrClass();
55 RegisterSpinnerClass();
56 fs_utils_InitMountRoot();
58 // Initialize our global variables and window classes
60 memset (&g, 0x00, sizeof(g));
61 g.fIsWinNT = IsWindowsNT();
62 g.fIsAdmin = IsAdmin();
64 // Check our command-line options
66 while (pCmdLine && (*pCmdLine=='/' || *pCmdLine=='-'))
68 switch (*(++pCmdLine))
76 while (*pCmdLine == ' ')
80 // Select an appropriate help file
83 lstrcpy (g.szHelpFile, TEXT("afs-cc.hlp>dialog"));
85 lstrcpy (g.szHelpFile, TEXT("afs-nt.hlp>dialog"));
87 lstrcpy (g.szHelpFile, TEXT("afs-light.hlp>dialog"));
89 // Our main window is actually a tabbed dialog.
91 if ((g.psh = PropSheet_Create (((g.fIsCCenter) ? IDS_TITLE_CCENTER : (g.fIsWinNT) ? IDS_TITLE_NT : IDS_TITLE_95), FALSE, NULL)) == NULL)
94 g.psh->sh.dwFlags |= PSH_NOAPPLYNOW; // Remove the Apply button
95 g.psh->sh.dwFlags |= PSH_HASHELP; // Add a Help button instead
99 PropSheet_AddTab (g.psh, 0, IDD_HOSTS_CCENTER, (DLGPROC)HostsTab_DlgProc, 0, TRUE);
103 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_GENERAL_NT : IDD_GENERAL_95), (DLGPROC)GeneralTab_DlgProc, 0, TRUE);
105 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_DRIVES_NT : IDD_DRIVES_95), (DLGPROC)DrivesTab_DlgProc, 0, TRUE);
108 PropSheet_AddTab (g.psh, 0, IDD_PREFS_NT, (DLGPROC)PrefsTab_DlgProc, 0, TRUE);
110 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_HOSTS_NT : IDD_HOSTS_95), (DLGPROC)HostsTab_DlgProc, 0, TRUE);
113 PropSheet_AddTab (g.psh, 0, IDD_ADVANCED_NT, (DLGPROC)AdvancedTab_DlgProc, 0, TRUE);
116 PropSheet_ShowModal (g.psh);
122 void Main_OnInitDialog (HWND hMain)
126 // Center the window in the display
129 GetWindowRect (g.hMain, &rWindow);
132 SystemParametersInfo (SPI_GETWORKAREA, 0, &rDesktop, 0);
134 SetWindowPos (g.hMain, NULL,
135 rDesktop.left + ((rDesktop.right - rDesktop.left) - (rWindow.right - rWindow.left)) / 2,
136 rDesktop.top + ((rDesktop.bottom - rDesktop.top) - (rWindow.bottom - rWindow.top)) / 2,
137 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
139 // Remove the Context Help [?] thing from the title bar
141 DWORD dwStyle = GetWindowLong (g.hMain, GWL_STYLE);
142 dwStyle &= ~DS_CONTEXTHELP;
143 SetWindowLong (g.hMain, GWL_STYLE, dwStyle);
145 dwStyle = GetWindowLong (hMain, GWL_EXSTYLE);
146 dwStyle &= ~WS_EX_CONTEXTHELP;
147 SetWindowLong (g.hMain, GWL_EXSTYLE, dwStyle);
151 void Main_RefreshAllTabs (void)
153 for (size_t ii = 0; ii < g.psh->cTabs; ++ii)
155 if (!g.psh->aTabs[ii].dlgproc)
157 if (!IsWindow (g.psh->aTabs[ii].hDlg))
160 CallWindowProc ((WNDPROC)(g.psh->aTabs[ii].dlgproc), g.psh->aTabs[ii].hDlg, WM_COMMAND, IDC_REFRESH, 0);
167 if (IsWindow (g.hMain))
169 DestroyWindow (g.hMain);
175 LPCTSTR GetCautionTitle (void)
177 static TCHAR szTitle[ cchRESOURCE ] = TEXT("");
179 GetString (szTitle, (g.fIsCCenter) ? IDS_TITLE_CAUTION_CCENTER : (g.fIsWinNT) ? IDS_TITLE_CAUTION_NT : IDS_TITLE_CAUTION_95);
184 LPCTSTR GetErrorTitle (void)
186 static TCHAR szTitle[ cchRESOURCE ] = TEXT("");
188 GetString (szTitle, (g.fIsCCenter) ? IDS_TITLE_ERROR_CCENTER : (g.fIsWinNT) ? IDS_TITLE_ERROR_NT : IDS_TITLE_ERROR_95);