6 #include "afs_config.h"
8 #include "tab_general.h"
10 #include "tab_hosts.h"
11 #include "tab_drives.h"
12 #include "tab_advanced.h"
16 * DEFINITIONS ________________________________________________________________
22 * VARIABLES __________________________________________________________________
30 * PROTOTYPES _________________________________________________________________
38 * ROUTINES ___________________________________________________________________
42 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();
57 // Initialize our global variables and window classes
59 memset (&g, 0x00, sizeof(g));
60 g.fIsWinNT = IsWindowsNT();
61 g.fIsAdmin = IsAdmin();
63 // Check our command-line options
65 while (pCmdLine && (*pCmdLine=='/' || *pCmdLine=='-'))
67 switch (*(++pCmdLine))
75 while (*pCmdLine == ' ')
79 // Select an appropriate help file
82 lstrcpy (g.szHelpFile, TEXT("afs-cc.hlp>dialog"));
84 lstrcpy (g.szHelpFile, TEXT("afs-nt.hlp>dialog"));
86 lstrcpy (g.szHelpFile, TEXT("afs-light.hlp>dialog"));
88 // Our main window is actually a tabbed dialog.
90 if ((g.psh = PropSheet_Create (((g.fIsCCenter) ? IDS_TITLE_CCENTER : (g.fIsWinNT) ? IDS_TITLE_NT : IDS_TITLE_95), FALSE, NULL)) == NULL)
93 g.psh->sh.dwFlags |= PSH_NOAPPLYNOW; // Remove the Apply button
94 g.psh->sh.dwFlags |= PSH_HASHELP; // Add a Help button instead
98 PropSheet_AddTab (g.psh, 0, IDD_HOSTS_CCENTER, (DLGPROC)HostsTab_DlgProc, 0, TRUE);
102 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_GENERAL_NT : IDD_GENERAL_95), (DLGPROC)GeneralTab_DlgProc, 0, TRUE);
104 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_DRIVES_NT : IDD_DRIVES_95), (DLGPROC)DrivesTab_DlgProc, 0, TRUE);
107 PropSheet_AddTab (g.psh, 0, IDD_PREFS_NT, (DLGPROC)PrefsTab_DlgProc, 0, TRUE);
109 PropSheet_AddTab (g.psh, 0, ((g.fIsWinNT) ? IDD_HOSTS_NT : IDD_HOSTS_95), (DLGPROC)HostsTab_DlgProc, 0, TRUE);
112 PropSheet_AddTab (g.psh, 0, IDD_ADVANCED_NT, (DLGPROC)AdvancedTab_DlgProc, 0, TRUE);
115 PropSheet_ShowModal (g.psh);
121 void Main_OnInitDialog (HWND hMain)
125 // Center the window in the display
128 GetWindowRect (g.hMain, &rWindow);
131 SystemParametersInfo (SPI_GETWORKAREA, 0, &rDesktop, 0);
133 SetWindowPos (g.hMain, NULL,
134 rDesktop.left + ((rDesktop.right - rDesktop.left) - (rWindow.right - rWindow.left)) / 2,
135 rDesktop.top + ((rDesktop.bottom - rDesktop.top) - (rWindow.bottom - rWindow.top)) / 2,
136 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER);
138 // Remove the Context Help [?] thing from the title bar
140 DWORD dwStyle = GetWindowLong (g.hMain, GWL_STYLE);
141 dwStyle &= ~DS_CONTEXTHELP;
142 SetWindowLong (g.hMain, GWL_STYLE, dwStyle);
144 dwStyle = GetWindowLong (hMain, GWL_EXSTYLE);
145 dwStyle &= ~WS_EX_CONTEXTHELP;
146 SetWindowLong (g.hMain, GWL_EXSTYLE, dwStyle);
150 void Main_RefreshAllTabs (void)
152 for (size_t ii = 0; ii < g.psh->cTabs; ++ii)
154 if (!g.psh->aTabs[ii].dlgproc)
156 if (!IsWindow (g.psh->aTabs[ii].hDlg))
159 CallWindowProc ((WNDPROC)(g.psh->aTabs[ii].dlgproc), g.psh->aTabs[ii].hDlg, WM_COMMAND, IDC_REFRESH, 0);
166 if (IsWindow (g.hMain))
168 DestroyWindow (g.hMain);
174 LPCTSTR GetCautionTitle (void)
176 static TCHAR szTitle[ cchRESOURCE ] = TEXT("");
178 GetString (szTitle, (g.fIsCCenter) ? IDS_TITLE_CAUTION_CCENTER : (g.fIsWinNT) ? IDS_TITLE_CAUTION_NT : IDS_TITLE_CAUTION_95);
183 LPCTSTR GetErrorTitle (void)
185 static TCHAR szTitle[ cchRESOURCE ] = TEXT("");
187 GetString (szTitle, (g.fIsCCenter) ? IDS_TITLE_ERROR_CCENTER : (g.fIsWinNT) ? IDS_TITLE_ERROR_NT : IDS_TITLE_ERROR_95);