Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
6.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998.
  5. //
  6. // File: CacheSet.h
  7. //
  8. // Contents: CCacheSettingsDlg implementation. Allows the setting of file sharing
  9. // caching options.
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "stdafx.h"
  13. #include "CacheSet.h"
  14. #include "filesvc.h"
  15. #include <htmlhelp.h>
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CCacheSettingsDlg dialog
  23. CCacheSettingsDlg::CCacheSettingsDlg(
  24. CWnd* pParent,
  25. DWORD& dwFlags)
  26. : CDialog(CCacheSettingsDlg::IDD, pParent),
  27. m_dwFlags (dwFlags)
  28. {
  29. //{{AFX_DATA_INIT(CCacheSettingsDlg)
  30. //}}AFX_DATA_INIT
  31. }
  32. void CCacheSettingsDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CCacheSettingsDlg)
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(CCacheSettingsDlg, CDialog)
  39. //{{AFX_MSG_MAP(CCacheSettingsDlg)
  40. ON_BN_CLICKED(IDC_CACHE_OPTIONS_MANUAL, OnCSCNoAuto)
  41. ON_BN_CLICKED(IDC_CACHE_OPTIONS_AUTO, OnCSCAuto)
  42. ON_BN_CLICKED(IDC_CACHE_OPTIONS_NOCACHE, OnCSCNoAuto)
  43. ON_BN_CLICKED(IDC_CACHE_OPTIONS_AUTO_CHECK, OnCSCAutoCheck)
  44. ON_NOTIFY(NM_CLICK, IDC_CACHE_HELPLINK, OnHelpLink)
  45. ON_NOTIFY(NM_RETURN, IDC_CACHE_HELPLINK, OnHelpLink)
  46. ON_MESSAGE(WM_HELP, OnHelp)
  47. ON_MESSAGE(WM_CONTEXTMENU, OnContextHelp)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CCacheSettingsDlg message handlers
  52. BOOL CCacheSettingsDlg::OnInitDialog()
  53. {
  54. CDialog::OnInitDialog();
  55. if (GetCachedFlag(m_dwFlags, CSC_CACHE_MANUAL_REINT))
  56. {
  57. CheckRadioButton(IDC_CACHE_OPTIONS_MANUAL,
  58. IDC_CACHE_OPTIONS_NOCACHE,
  59. IDC_CACHE_OPTIONS_MANUAL);
  60. } else if (GetCachedFlag(m_dwFlags, CSC_CACHE_AUTO_REINT))
  61. {
  62. CheckRadioButton(IDC_CACHE_OPTIONS_MANUAL,
  63. IDC_CACHE_OPTIONS_NOCACHE,
  64. IDC_CACHE_OPTIONS_AUTO);
  65. CheckDlgButton(IDC_CACHE_OPTIONS_AUTO_CHECK, BST_UNCHECKED);
  66. } else if (GetCachedFlag(m_dwFlags, CSC_CACHE_VDO))
  67. {
  68. CheckRadioButton(IDC_CACHE_OPTIONS_MANUAL,
  69. IDC_CACHE_OPTIONS_NOCACHE,
  70. IDC_CACHE_OPTIONS_AUTO);
  71. CheckDlgButton(IDC_CACHE_OPTIONS_AUTO_CHECK, BST_CHECKED);
  72. } else if (GetCachedFlag(m_dwFlags, CSC_CACHE_NONE))
  73. {
  74. CheckRadioButton(IDC_CACHE_OPTIONS_MANUAL,
  75. IDC_CACHE_OPTIONS_NOCACHE,
  76. IDC_CACHE_OPTIONS_NOCACHE);
  77. }
  78. return TRUE; // return TRUE unless you set the focus to a control
  79. // EXCEPTION: OCX Property Pages should return FALSE
  80. }
  81. void CCacheSettingsDlg::OnCSCNoAuto()
  82. {
  83. CheckDlgButton(IDC_CACHE_OPTIONS_AUTO_CHECK, BST_UNCHECKED);
  84. HWND hwnd = GetDlgItem(IDC_CACHE_OPTIONS_AUTO_CHECK)->GetSafeHwnd();
  85. LONG_PTR lStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
  86. if (0 != lStyle)
  87. SetWindowLongPtr(hwnd, GWL_STYLE, lStyle & ~WS_TABSTOP);
  88. }
  89. void CCacheSettingsDlg::OnCSCAuto()
  90. {
  91. CheckDlgButton(IDC_CACHE_OPTIONS_AUTO_CHECK, BST_CHECKED);
  92. HWND hwnd = GetDlgItem(IDC_CACHE_OPTIONS_AUTO_CHECK)->GetSafeHwnd();
  93. LONG_PTR lStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
  94. if (0 != lStyle)
  95. SetWindowLongPtr(hwnd, GWL_STYLE, lStyle | WS_TABSTOP);
  96. }
  97. void CCacheSettingsDlg::OnCSCAutoCheck()
  98. {
  99. CheckRadioButton(IDC_CACHE_OPTIONS_MANUAL,
  100. IDC_CACHE_OPTIONS_NOCACHE,
  101. IDC_CACHE_OPTIONS_AUTO);
  102. HWND hwnd = GetDlgItem(IDC_CACHE_OPTIONS_AUTO_CHECK)->GetSafeHwnd();
  103. LONG_PTR lStyle = GetWindowLongPtr(hwnd, GWL_STYLE);
  104. if (0 != lStyle)
  105. SetWindowLongPtr(hwnd, GWL_STYLE, lStyle | WS_TABSTOP);
  106. }
  107. void CCacheSettingsDlg::OnHelpLink(NMHDR* pNMHDR, LRESULT* pResult)
  108. {
  109. CWaitCursor wait;
  110. ::HtmlHelp(0, _T("file_srv.chm"), HH_DISPLAY_TOPIC, (DWORD_PTR)(_T("file_srv_cache_options.htm")));
  111. *pResult = 0;
  112. }
  113. void CCacheSettingsDlg::OnOK()
  114. {
  115. DWORD dwNewFlag = 0;
  116. switch (GetCheckedRadioButton(IDC_CACHE_OPTIONS_MANUAL, IDC_CACHE_OPTIONS_NOCACHE))
  117. {
  118. case IDC_CACHE_OPTIONS_MANUAL:
  119. dwNewFlag = CSC_CACHE_MANUAL_REINT;
  120. break;
  121. case IDC_CACHE_OPTIONS_AUTO:
  122. if (BST_CHECKED != IsDlgButtonChecked(IDC_CACHE_OPTIONS_AUTO_CHECK))
  123. dwNewFlag = CSC_CACHE_AUTO_REINT;
  124. else
  125. dwNewFlag = CSC_CACHE_VDO;
  126. break;
  127. case IDC_CACHE_OPTIONS_NOCACHE:
  128. dwNewFlag = CSC_CACHE_NONE;
  129. break;
  130. default:
  131. break;
  132. }
  133. SetCachedFlag (&m_dwFlags, dwNewFlag);
  134. CDialog::OnOK();
  135. }
  136. BOOL CCacheSettingsDlg::GetCachedFlag( DWORD dwFlags, DWORD dwFlagToCheck )
  137. {
  138. return (dwFlags & CSC_MASK) == dwFlagToCheck;
  139. }
  140. VOID CCacheSettingsDlg::SetCachedFlag( DWORD* pdwFlags, DWORD dwNewFlag )
  141. {
  142. *pdwFlags &= ~CSC_MASK;
  143. *pdwFlags |= dwNewFlag;
  144. }
  145. /////////////////////////////////////////////////////////////////////
  146. // Help
  147. BOOL CCacheSettingsDlg::OnHelp(WPARAM /*wParam*/, LPARAM lParam)
  148. {
  149. return DoHelp(lParam, HELP_DIALOG_TOPIC(IDD_SMB_CACHE_SETTINGS));
  150. }
  151. BOOL CCacheSettingsDlg::OnContextHelp(WPARAM wParam, LPARAM /*lParam*/)
  152. {
  153. return DoContextHelp(wParam, HELP_DIALOG_TOPIC(IDD_SMB_CACHE_SETTINGS));
  154. }
  155. ///////////////////////////////////////////////////////////////////////////////
  156. // CacheSettingsDlg ()
  157. //
  158. // Invoke a dialog to set/modify cache settings for a share
  159. //
  160. // RETURNS
  161. // Return S_OK if the user clicked on the OK button.
  162. // Return S_FALSE if the user clicked on the Cancel button.
  163. // Return E_OUTOFMEMORY if there is not enough memory.
  164. // Return E_UNEXPECTED if an expected error occured (eg: bad parameter)
  165. //
  166. ///////////////////////////////////////////////////////////////////////////////
  167. HRESULT
  168. CacheSettingsDlg(
  169. HWND hwndParent, // IN: Parent's window handle
  170. DWORD& dwFlags) // IN & OUT: share flags
  171. {
  172. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  173. ASSERT(::IsWindow(hwndParent));
  174. HRESULT hResult = S_OK;
  175. CWnd parentWnd;
  176. parentWnd.Attach (hwndParent);
  177. CCacheSettingsDlg dlg (&parentWnd, dwFlags);
  178. CThemeContextActivator activator;
  179. if (IDOK != dlg.DoModal())
  180. hResult = S_FALSE;
  181. parentWnd.Detach ();
  182. return hResult;
  183. } // CacheSettingsDlg()