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.

203 lines
5.6 KiB

  1. /****************************************************************************\
  2. *
  3. * introdlg.cpp
  4. *
  5. * Created: William Taylor (wtaylor) 01/22/01
  6. *
  7. * MS Ratings Introduction Property Page
  8. *
  9. \****************************************************************************/
  10. #include "msrating.h"
  11. #include "mslubase.h"
  12. #include "parselbl.h"
  13. #include "picsrule.h"
  14. #include "introdlg.h" // CIntroDialog
  15. #include "toffdlg.h" // CTurnOffDialog
  16. #include "hint.h" // CHint
  17. #include "debug.h" // TraceMsg()
  18. #include <contxids.h> // Help Context ID's
  19. #include <mluisupp.h> // SHWinHelpOnDemandWrap() and MLLoadStringA()
  20. extern INT_PTR DoPasswordConfirm(HWND hDlg);
  21. extern BOOL PicsOptionsDialog( HWND hwnd, PicsRatingSystemInfo * pPRSI, PicsUser * pPU );
  22. const UINT PASSCONFIRM_FAIL = 0;
  23. const UINT PASSCONFIRM_OK = 1;
  24. const UINT PASSCONFIRM_NEW = 2;
  25. DWORD CIntroDialog::aIds[] = {
  26. IDC_SET_RATINGS, IDH_RATINGS_SET_RATINGS_BUTTON,
  27. IDC_STATIC1, IDH_IGNORE,
  28. IDC_TURN_ONOFF, IDH_RATINGS_TURNON_BUTTON,
  29. IDC_INTRO_TEXT, IDH_IGNORE,
  30. 0,0
  31. };
  32. CIntroDialog::CIntroDialog()
  33. {
  34. // Add Construction Here...
  35. }
  36. LRESULT CIntroDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  37. {
  38. CheckGlobalInfoRev();
  39. EnableDlgItems();
  40. bHandled = FALSE;
  41. return 1L; // Let the system set the focus
  42. }
  43. LRESULT CIntroDialog::OnSetRatings(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  44. {
  45. HWND hDlg = m_hWnd;
  46. UINT_PTR passConfirm = DoPasswordConfirm(hDlg);
  47. if (passConfirm == PASSCONFIRM_FAIL)
  48. {
  49. TraceMsg( TF_WARNING, "CIntroDialog::OnSetRatings() - DoPasswordConfirm() failed." );
  50. return 0L;
  51. }
  52. if (!gPRSI->fRatingInstalled)
  53. {
  54. gPRSI->FreshInstall();
  55. if ( ! PicsOptionsDialog( hDlg, gPRSI, GetUserObject() ) )
  56. {
  57. if (passConfirm == PASSCONFIRM_NEW)
  58. {
  59. RemoveSupervisorPassword();
  60. }
  61. }
  62. MarkChanged();
  63. }
  64. else
  65. {
  66. if ( PicsOptionsDialog( hDlg, gPRSI, GetUserObject() ) )
  67. {
  68. MarkChanged();
  69. }
  70. }
  71. EnableDlgItems();
  72. return 1L;
  73. }
  74. LRESULT CIntroDialog::OnTurnOnOff(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  75. {
  76. HWND hDlg = m_hWnd;
  77. if ( DoPasswordConfirm( hDlg ) )
  78. {
  79. PicsUser *pUser = ::GetUserObject();
  80. if (pUser != NULL)
  81. {
  82. pUser->fEnabled = !pUser->fEnabled;
  83. if (pUser->fEnabled)
  84. {
  85. MyMessageBox(hDlg, IDS_NOW_ON, IDS_ENABLE_WARNING,
  86. IDS_GENERIC, MB_OK);
  87. }
  88. else
  89. {
  90. CRegKey keyRatings;
  91. if ( keyRatings.Open( HKEY_LOCAL_MACHINE, szRATINGS ) == ERROR_SUCCESS )
  92. {
  93. DWORD dwFlag;
  94. // $REVIEW - Should we call RemoveSupervisorPassword() or not delete the Key at all?
  95. // Delete the supervisor key so that we don't load
  96. // ratings by other components and we "quick" know it is off.
  97. keyRatings.DeleteValue( szRatingsSupervisorKeyName );
  98. if ( keyRatings.QueryValue( dwFlag, szTURNOFF ) == ERROR_SUCCESS )
  99. {
  100. if ( dwFlag != 1 )
  101. {
  102. CTurnOffDialog turnOffDialog;
  103. turnOffDialog.DoModal( hDlg );
  104. }
  105. }
  106. else
  107. {
  108. CTurnOffDialog turnOffDialog;
  109. turnOffDialog.DoModal( hDlg );
  110. }
  111. }
  112. }
  113. EnableDlgItems();
  114. }
  115. }
  116. return 1L;
  117. }
  118. LRESULT CIntroDialog::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  119. {
  120. ASSERT( gPRSI );
  121. if ( gPRSI )
  122. {
  123. gPRSI->fSettingsValid = TRUE;
  124. gPRSI->SaveRatingSystemInfo();
  125. }
  126. return PSNRET_NOERROR;
  127. }
  128. LRESULT CIntroDialog::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  129. {
  130. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  131. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  132. return 0L;
  133. }
  134. LRESULT CIntroDialog::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  135. {
  136. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  137. (DWORD_PTR)(LPVOID)aIds);
  138. return 0L;
  139. }
  140. void CIntroDialog::EnableDlgItems( void )
  141. {
  142. CHAR pszBuf[MAXPATHLEN];
  143. PicsUser *pUser = ::GetUserObject();
  144. if (!gPRSI->fRatingInstalled)
  145. {
  146. MLLoadStringA(IDS_RATING_NEW, pszBuf, sizeof(pszBuf));
  147. SetDlgItemText( IDC_INTRO_TEXT, pszBuf);
  148. MLLoadStringA(IDS_TURN_ONOFF, pszBuf, sizeof(pszBuf));
  149. SetDlgItemText( IDC_TURN_ONOFF, pszBuf);
  150. ::EnableWindow(GetDlgItem( IDC_TURN_ONOFF), FALSE);
  151. }
  152. else if (pUser && pUser->fEnabled)
  153. {
  154. MLLoadStringA(IDS_RATING_ON, pszBuf, sizeof(pszBuf));
  155. SetDlgItemText( IDC_INTRO_TEXT, pszBuf);
  156. MLLoadStringA(IDS_TURN_OFF, pszBuf, sizeof(pszBuf));
  157. SetDlgItemText( IDC_TURN_ONOFF, pszBuf);
  158. ::EnableWindow(GetDlgItem( IDC_TURN_ONOFF), TRUE);
  159. }
  160. else
  161. {
  162. MLLoadStringA(IDS_RATING_OFF, pszBuf, sizeof(pszBuf));
  163. SetDlgItemText( IDC_INTRO_TEXT, pszBuf);
  164. MLLoadStringA(IDS_TURN_ON, pszBuf, sizeof(pszBuf));
  165. SetDlgItemText( IDC_TURN_ONOFF, pszBuf);
  166. ::EnableWindow(GetDlgItem( IDC_TURN_ONOFF), TRUE);
  167. }
  168. }