Source code of Windows XP (NT5)
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.

276 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. propsdlg.h
  5. Abstract:
  6. Link checker properties dialog class implementation.
  7. Author:
  8. Michael Cheuk (mcheuk)
  9. Project:
  10. Link Checker
  11. Revision History:
  12. --*/
  13. #include "stdafx.h"
  14. #include "linkchk.h"
  15. #include "propsdlg.h"
  16. #include "lcmgr.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. CPropertiesDialog::CPropertiesDialog(
  23. CWnd* pParent /*=NULL*/
  24. ) :
  25. /*++
  26. Routine Description:
  27. Constructor.
  28. Arguments:
  29. pParent - pointer to parent CWnd
  30. Return Value:
  31. N/A
  32. --*/
  33. CDialog(CPropertiesDialog::IDD, pParent)
  34. {
  35. //{{AFX_DATA_INIT(CPropertiesDialog)
  36. // NOTE: the ClassWizard will add member initialization here
  37. //}}AFX_DATA_INIT
  38. } // CPropertiesDialog::CPropertiesDialog
  39. void
  40. CPropertiesDialog::DoDataExchange(
  41. CDataExchange* pDX
  42. )
  43. /*++
  44. Routine Description:
  45. Called by MFC to change/retrieve dialog data
  46. Arguments:
  47. pDX -
  48. Return Value:
  49. N/A
  50. --*/
  51. {
  52. CDialog::DoDataExchange(pDX);
  53. //{{AFX_DATA_MAP(CPropertiesDialog)
  54. DDX_Control(pDX, IDC_LANGUAGE_LIST, m_LanguageCheckList);
  55. DDX_Control(pDX, IDC_BROWSER_LIST, m_BrowserCheckList);
  56. //}}AFX_DATA_MAP
  57. } // CPropertiesDialog::DoDataExchange
  58. BEGIN_MESSAGE_MAP(CPropertiesDialog, CDialog)
  59. //{{AFX_MSG_MAP(CPropertiesDialog)
  60. ON_BN_CLICKED(IDC_PROPERTIES_OK, OnPropertiesOk)
  61. //}}AFX_MSG_MAP
  62. ON_BN_CLICKED(IDC_PROPERTIES_CANCEL, CDialog::OnCancel)
  63. END_MESSAGE_MAP()
  64. BOOL
  65. CPropertiesDialog::OnInitDialog(
  66. )
  67. /*++
  68. Routine Description:
  69. WM_INITDIALOG message handler
  70. Arguments:
  71. N/A
  72. Return Value:
  73. BOOL - TRUE if sucess. FALSE otherwise.
  74. --*/
  75. {
  76. CDialog::OnInitDialog();
  77. // Add all the avaiable browsers to checked list box
  78. CUserOptions& UserOptions = GetLinkCheckerMgr().GetUserOptions();
  79. int iSize = UserOptions.GetAvailableBrowsers().GetCount();
  80. if(iSize > 0)
  81. {
  82. CBrowserInfo BrowserInfo;
  83. POSITION PosBrowser = UserOptions.GetAvailableBrowsers().GetHeadPosition();
  84. for(int i=0; i<iSize; i++)
  85. {
  86. BrowserInfo = UserOptions.GetAvailableBrowsers().GetNext(PosBrowser);
  87. if(i != m_BrowserCheckList.AddString(BrowserInfo.GetName()))
  88. {
  89. ASSERT(FALSE);
  90. return FALSE;
  91. }
  92. else
  93. {
  94. // Make sure they all checked
  95. int iChecked = BrowserInfo.IsSelected() ? 1 : 0;
  96. m_BrowserCheckList.SetCheck(i, iChecked);
  97. }
  98. }
  99. }
  100. // Add all the avaiable languages to checked list box
  101. iSize = UserOptions.GetAvailableLanguages().GetCount();
  102. if(iSize > 0)
  103. {
  104. CLanguageInfo LanguageInfo;
  105. POSITION PosLanguage = UserOptions.GetAvailableLanguages().GetHeadPosition();
  106. for(int i=0; i<iSize; i++)
  107. {
  108. LanguageInfo = UserOptions.GetAvailableLanguages().GetNext(PosLanguage);
  109. if(i != m_LanguageCheckList.AddString(LanguageInfo.GetName()))
  110. {
  111. ASSERT(FALSE);
  112. return FALSE;
  113. }
  114. else
  115. {
  116. // Make sure they all checked
  117. int iChecked = LanguageInfo.IsSelected() ? 1 : 0;
  118. m_LanguageCheckList.SetCheck(i, iChecked);
  119. }
  120. }
  121. }
  122. return TRUE; // return TRUE unless you set the focus to a control
  123. // EXCEPTION: OCX Property Pages should return FALSE
  124. } // CPropertiesDialog::OnInitDialog
  125. void
  126. CPropertiesDialog::OnPropertiesOk(
  127. )
  128. /*++
  129. Routine Description:
  130. OK button click handler. This functions add all the user checked
  131. item to CUserOptions.
  132. Arguments:
  133. N/A
  134. Return Value:
  135. N/A
  136. --*/
  137. {
  138. // Make sure we have at least one item checked
  139. if(NumItemsChecked(m_BrowserCheckList) == 0 || NumItemsChecked(m_LanguageCheckList) == 0)
  140. {
  141. AfxMessageBox(IDS_ITEM_NOT_CHECKED);
  142. return;
  143. }
  144. // Add the checked browsers to CUserOptions
  145. CUserOptions& UserOptions = GetLinkCheckerMgr().GetUserOptions();
  146. int iSize = UserOptions.GetAvailableBrowsers().GetCount();
  147. if(iSize)
  148. {
  149. POSITION PosBrowser = UserOptions.GetAvailableBrowsers().GetHeadPosition();
  150. for(int i=0; i<iSize; i++)
  151. {
  152. CBrowserInfo& BrowserInfo = UserOptions.GetAvailableBrowsers().GetNext(PosBrowser);
  153. BrowserInfo.SetSelect(m_BrowserCheckList.GetCheck(i) == 1);
  154. }
  155. }
  156. // Add the checked languages to CUserOptions
  157. iSize = UserOptions.GetAvailableLanguages().GetCount();
  158. if(iSize)
  159. {
  160. POSITION PosLanguage = UserOptions.GetAvailableLanguages().GetHeadPosition();
  161. for(int i=0; i<iSize; i++)
  162. {
  163. CLanguageInfo& LanguageInfo = UserOptions.GetAvailableLanguages().GetNext(PosLanguage);
  164. LanguageInfo.SetSelect(m_LanguageCheckList.GetCheck(i) == 1);
  165. }
  166. }
  167. CDialog::OnOK();
  168. } // CPropertiesDialog::OnPropertiesOk
  169. int
  170. CPropertiesDialog::NumItemsChecked(
  171. CCheckListBox& ListBox
  172. )
  173. /*++
  174. Routine Description:
  175. Get the number of items checked in a check listbox.
  176. Arguments:
  177. N/A
  178. Return Value:
  179. int - number of items checked.
  180. --*/
  181. {
  182. int iCheckedCount = 0;
  183. int iSize = ListBox.GetCount();
  184. for(int i=0; i<iSize; i++)
  185. {
  186. if(ListBox.GetCheck(i) == 1)
  187. {
  188. iCheckedCount++;
  189. }
  190. }
  191. return iCheckedCount;
  192. } // CPropertiesDialog::NumItemsChecked