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 <afs/param.h>
16 #include <afs/fs_utils.h>
19 #include "afs_config.h"
21 #include "tab_general.h"
22 #include "tab_prefs.h"
23 #include "tab_hosts.h"
24 #include "tab_drives.h"
25 #include "tab_advanced.h"
28 * DEFINITIONS ________________________________________________________________
34 * VARIABLES __________________________________________________________________
41 * ROUTINES ___________________________________________________________________
45 static BOOL
Main_ShowMountTab(void)
49 BOOL bSuccess
= FALSE
;
51 if (RegOpenKeyEx (HKEY_CURRENT_USER
, AFSREG_USER_OPENAFS_SUBKEY
, 0,
52 (IsWow64()?KEY_WOW64_64KEY
:0)|KEY_QUERY_VALUE
, &hk
) == 0)
54 DWORD dwSize
= sizeof(bShow
);
55 DWORD dwType
= REG_DWORD
;
56 bSuccess
= (RegQueryValueEx (hk
, TEXT("ShowMountTab"), NULL
, &dwType
, (PBYTE
)&bShow
, &dwSize
) == 0);
61 RegOpenKeyEx (HKEY_LOCAL_MACHINE
, AFSREG_CLT_OPENAFS_SUBKEY
, 0,
62 (IsWow64()?KEY_WOW64_64KEY
:0)|KEY_QUERY_VALUE
, &hk
) == 0)
64 DWORD dwSize
= sizeof(bShow
);
65 DWORD dwType
= REG_DWORD
;
66 bSuccess
= (RegQueryValueEx (hk
, TEXT("ShowMountTab"), NULL
, &dwType
, (PBYTE
)&bShow
, &dwSize
) == 0);
73 extern "C" int WINAPI
WinMain (HINSTANCE hInst
, HINSTANCE hPrev
, LPSTR pCmdLine
, int nCmdShow
)
75 TaLocale_LoadCorrespondingModule (hInst
);
77 // Initialize winsock etc
80 WSAStartup (0x0101, &Data
);
83 RegisterCheckListClass();
84 RegisterFastListClass();
85 RegisterSockAddrClass();
86 RegisterSpinnerClass();
87 fs_utils_InitMountRoot();
89 // Initialize our global variables and window classes
91 memset (&g
, 0x00, sizeof(g
));
92 g
.fIsWinNT
= IsWindowsNT();
93 g
.fIsAdmin
= IsAdmin();
95 // Check our command-line options
97 while (pCmdLine
&& (*pCmdLine
=='/' || *pCmdLine
=='-'))
99 switch (*(++pCmdLine
))
107 while (*pCmdLine
== ' ')
111 // Select an appropriate help file
114 lstrcpy (g
.szHelpFile
, TEXT("afs-cc.hlp>dialog"));
116 lstrcpy (g
.szHelpFile
, TEXT("afs-nt.hlp>dialog"));
118 lstrcpy (g
.szHelpFile
, TEXT("afs-light.hlp>dialog"));
120 // Our main window is actually a tabbed dialog.
122 if ((g
.psh
= PropSheet_Create (((g
.fIsCCenter
) ? IDS_TITLE_CCENTER
: (g
.fIsWinNT
) ? IDS_TITLE_NT
: IDS_TITLE_95
), FALSE
, NULL
)) == NULL
)
125 g
.psh
->sh
.dwFlags
|= PSH_NOAPPLYNOW
; // Remove the Apply button
126 g
.psh
->sh
.dwFlags
|= PSH_HASHELP
; // Add a Help button instead
130 PropSheet_AddTab (g
.psh
, 0, IDD_HOSTS_CCENTER
, (DLGPROC
)HostsTab_DlgProc
, 0, TRUE
);
134 PropSheet_AddTab (g
.psh
, 0, ((g
.fIsWinNT
) ? IDD_GENERAL_NT
: IDD_GENERAL_95
), (DLGPROC
)GeneralTab_DlgProc
, 0, TRUE
);
136 if (Main_ShowMountTab())
137 PropSheet_AddTab (g
.psh
, 0, ((g
.fIsWinNT
) ? IDD_DRIVES_NT
: IDD_DRIVES_95
), (DLGPROC
)DrivesTab_DlgProc
, 0, TRUE
);
140 PropSheet_AddTab (g
.psh
, 0, IDD_PREFS_NT
, (DLGPROC
)PrefsTab_DlgProc
, 0, TRUE
);
142 PropSheet_AddTab (g
.psh
, 0, ((g
.fIsWinNT
) ? IDD_HOSTS_NT
: IDD_HOSTS_95
), (DLGPROC
)HostsTab_DlgProc
, 0, TRUE
);
145 PropSheet_AddTab (g
.psh
, 0, IDD_ADVANCED_NT
, (DLGPROC
)AdvancedTab_DlgProc
, 0, TRUE
);
148 PropSheet_ShowModal (g
.psh
);
154 void Main_OnInitDialog (HWND hMain
)
158 // Center the window in the display
161 GetWindowRect (g
.hMain
, &rWindow
);
164 SystemParametersInfo (SPI_GETWORKAREA
, 0, &rDesktop
, 0);
166 SetWindowPos (g
.hMain
, NULL
,
167 rDesktop
.left
+ ((rDesktop
.right
- rDesktop
.left
) - (rWindow
.right
- rWindow
.left
)) / 2,
168 rDesktop
.top
+ ((rDesktop
.bottom
- rDesktop
.top
) - (rWindow
.bottom
- rWindow
.top
)) / 2,
169 0, 0, SWP_NOSIZE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
171 // Remove the Context Help [?] thing from the title bar
173 DWORD dwStyle
= GetWindowLong (g
.hMain
, GWL_STYLE
);
174 dwStyle
&= ~DS_CONTEXTHELP
;
175 SetWindowLong (g
.hMain
, GWL_STYLE
, dwStyle
);
177 dwStyle
= GetWindowLong (hMain
, GWL_EXSTYLE
);
178 dwStyle
&= ~WS_EX_CONTEXTHELP
;
179 SetWindowLong (g
.hMain
, GWL_EXSTYLE
, dwStyle
);
183 void Main_RefreshAllTabs (void)
185 for (size_t ii
= 0; ii
< g
.psh
->cTabs
; ++ii
)
187 if (!g
.psh
->aTabs
[ii
].dlgproc
)
189 if (!IsWindow (g
.psh
->aTabs
[ii
].hDlg
))
192 CallWindowProc ((WNDPROC
)(g
.psh
->aTabs
[ii
].dlgproc
), g
.psh
->aTabs
[ii
].hDlg
, WM_COMMAND
, IDC_REFRESH
, 0);
199 if (IsWindow (g
.hMain
))
201 DestroyWindow (g
.hMain
);
207 LPCTSTR
GetCautionTitle (void)
209 static TCHAR szTitle
[ cchRESOURCE
] = TEXT("");
211 GetString (szTitle
, (g
.fIsCCenter
) ? IDS_TITLE_CAUTION_CCENTER
: (g
.fIsWinNT
) ? IDS_TITLE_CAUTION_NT
: IDS_TITLE_CAUTION_95
);
216 LPCTSTR
GetErrorTitle (void)
218 static TCHAR szTitle
[ cchRESOURCE
] = TEXT("");
220 GetString (szTitle
, (g
.fIsCCenter
) ? IDS_TITLE_ERROR_CCENTER
: (g
.fIsWinNT
) ? IDS_TITLE_ERROR_NT
: IDS_TITLE_ERROR_95
);