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.

248 lines
6.7 KiB

  1. /****************************************************************************\
  2. *
  3. * gendlg.cpp
  4. *
  5. * Created: William Taylor (wtaylor) 01/22/01
  6. *
  7. * MS Ratings General Property Page
  8. *
  9. \****************************************************************************/
  10. #include "msrating.h"
  11. #include "mslubase.h"
  12. #include "gendlg.h" // CGeneralDialog
  13. #include "debug.h" // TraceMsg()
  14. #include "chngdlg.h" // CChangePasswordDialog
  15. #include <contxids.h> // Help Context ID's
  16. #include <mluisupp.h> // SHWinHelpOnDemandWrap() and MLLoadStringA()
  17. DWORD CGeneralDialog::aIds[] = {
  18. IDC_STATIC7, IDH_IGNORE,
  19. IDC_STATIC1, IDH_RATINGS_CHANGE_PASSWORD_BUTTON,
  20. IDC_STATIC2, IDH_RATINGS_CHANGE_PASSWORD_BUTTON,
  21. IDC_STATIC3, IDH_RATINGS_CHANGE_PASSWORD_BUTTON,
  22. IDC_FINDRATINGS, IDH_FIND_RATING_SYSTEM_BUTTON,
  23. IDC_PROVIDER, IDH_RATINGS_RATING_SYSTEM_BUTTON,
  24. IDC_UNRATED, IDH_RATINGS_UNRATED_CHECKBOX,
  25. IDC_PLEASE_MOMMY, IDH_RATINGS_OVERRIDE_CHECKBOX,
  26. IDC_STATIC4, IDH_RATINGS_RATING_SYSTEM_TEXT,
  27. IDC_STATIC5, IDH_RATINGS_RATING_SYSTEM_TEXT,
  28. IDC_STATIC6, IDH_RATINGS_RATING_SYSTEM_TEXT,
  29. IDC_CHANGE_PASSWORD, IDH_RATINGS_CHANGE_PASSWORD_BUTTON,
  30. 0,0
  31. };
  32. CGeneralDialog::CGeneralDialog( PRSD * p_pPRSD )
  33. {
  34. ASSERT( p_pPRSD );
  35. m_pPRSD = p_pPRSD;
  36. }
  37. LRESULT CGeneralDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  38. {
  39. PRSD * pPRSD = m_pPRSD;
  40. ASSERT( pPRSD );
  41. if ( ! pPRSD )
  42. {
  43. TraceMsg( TF_ERROR, "CApprovedSitesDialog::OnInitDialog() - pPRSD is NULL!" );
  44. return 0L;
  45. }
  46. if (pPRSD->pPU != NULL)
  47. {
  48. CheckDlgButton( IDC_UNRATED, pPRSD->pPU->fAllowUnknowns?BST_CHECKED:BST_UNCHECKED);
  49. CheckDlgButton( IDC_PLEASE_MOMMY, pPRSD->pPU->fPleaseMom?BST_CHECKED:BST_UNCHECKED);
  50. }
  51. SetButtonText();
  52. PostMessage( WM_USER,(WPARAM) 0,(LPARAM) 0);
  53. bHandled = FALSE;
  54. return 1L; // Let the system set the focus
  55. }
  56. LRESULT CGeneralDialog::OnUser(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  57. {
  58. if (gPRSI->lpszFileName!=NULL)
  59. {
  60. ::SetFocus(GetDlgItem(IDC_PROVIDER));
  61. DoProviderDialog( m_hWnd,gPRSI );
  62. gPRSI->lpszFileName=NULL;
  63. }
  64. return 0L;
  65. }
  66. LRESULT CGeneralDialog::OnProvider(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  67. {
  68. PRSD * pPRSD = m_pPRSD;
  69. ASSERT( pPRSD );
  70. if ( ! pPRSD )
  71. {
  72. TraceMsg( TF_ERROR, "CGeneralDialog::OnProvider() - pPRSD is NULL!" );
  73. return 0L;
  74. }
  75. if ( DoProviderDialog( m_hWnd, pPRSD->pPRSI ) )
  76. {
  77. pPRSD->fNewProviders = TRUE;
  78. MarkChanged();
  79. // $BUG - $BUG - The Bureau List is on the Advanced Dialog so this seems incorrect!!
  80. // FillBureauList(hDlg, pPRSD->pPRSI);
  81. }
  82. return 1L;
  83. }
  84. LRESULT CGeneralDialog::OnFindRatings(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  85. {
  86. BOOL fSuccess=FALSE;
  87. HINSTANCE hShell32=::LoadLibrary(::szShell32);
  88. if(hShell32!=NULL)
  89. {
  90. PFNSHELLEXECUTE pfnShellExecute=(PFNSHELLEXECUTE)::GetProcAddress(hShell32,::szShellExecute);
  91. if(pfnShellExecute!=NULL)
  92. {
  93. fSuccess=(*pfnShellExecute)(m_hWnd,NULL,(char *) &szFINDSYSTEM,NULL,NULL,SW_SHOW)!=NULL;
  94. }
  95. ::FreeLibrary(hShell32);
  96. }
  97. if (!fSuccess)
  98. {
  99. NLS_STR nlsMessage(MAX_RES_STR_LEN);
  100. //Check for NULL; Otherwise, nlsMessage.QueryPch() will fault later.
  101. if(nlsMessage)
  102. {
  103. NLS_STR nlsTemp(STR_OWNERALLOC,(char *) &szFINDSYSTEM);
  104. const NLS_STR *apnls[] = { &nlsTemp, NULL };
  105. if ( WN_SUCCESS == (nlsMessage.LoadString(IDS_CANT_LAUNCH, apnls)) )
  106. {
  107. MyMessageBox(m_hWnd,nlsMessage.QueryPch(),IDS_GENERIC,MB_OK|MB_ICONSTOP);
  108. }
  109. }
  110. }
  111. return 1L;
  112. }
  113. LRESULT CGeneralDialog::OnMarkChanged(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  114. {
  115. MarkChanged();
  116. return 1L;
  117. }
  118. LRESULT CGeneralDialog::OnChangePassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  119. {
  120. int idsMessage = 0;
  121. if ( SUCCEEDED( VerifySupervisorPassword() ) )
  122. {
  123. CChangePasswordDialog<IDD_CHANGE_PASSWORD> changePasswordDlg;
  124. if ( changePasswordDlg.DoModal( m_hWnd ) )
  125. {
  126. idsMessage = IDS_PASSWORD_CHANGED;
  127. }
  128. }
  129. else
  130. {
  131. CChangePasswordDialog<IDD_CREATE_PASSWORD> createPassDlg;
  132. if ( createPassDlg.DoModal( m_hWnd ) )
  133. {
  134. SetButtonText();
  135. idsMessage = IDS_PASSWORD_CREATED;
  136. }
  137. }
  138. if ( idsMessage )
  139. {
  140. MyMessageBox( m_hWnd, idsMessage, IDS_GENERIC, MB_OK | MB_ICONINFORMATION);
  141. MarkChanged();
  142. }
  143. return 1L;
  144. }
  145. LRESULT CGeneralDialog::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  146. {
  147. LPPSHNOTIFY lpPSHNotify = (LPPSHNOTIFY) pnmh;
  148. /*do apply stuff*/
  149. PRSD * pPRSD = m_pPRSD;
  150. ASSERT( pPRSD );
  151. if ( ! pPRSD )
  152. {
  153. TraceMsg( TF_ERROR, "CGeneralDialog::OnApply() - pPRSD is NULL!" );
  154. return 0L;
  155. }
  156. if (pPRSD->pPU != NULL)
  157. {
  158. pPRSD->pPU->fAllowUnknowns = (IsDlgButtonChecked(IDC_UNRATED) & BST_CHECKED) ? TRUE: FALSE;
  159. pPRSD->pPU->fPleaseMom = (IsDlgButtonChecked(IDC_PLEASE_MOMMY) & BST_CHECKED) ? TRUE: FALSE;
  160. }
  161. return PSNRET_NOERROR;
  162. }
  163. LRESULT CGeneralDialog::OnReset(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  164. {
  165. return 0L;
  166. }
  167. LRESULT CGeneralDialog::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  168. {
  169. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  170. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  171. return 0L;
  172. }
  173. LRESULT CGeneralDialog::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  174. {
  175. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  176. (DWORD_PTR)(LPVOID)aIds);
  177. return 0L;
  178. }
  179. void CGeneralDialog::SetButtonText( void )
  180. {
  181. int idsButton;
  182. if ( SUCCEEDED( VerifySupervisorPassword() ) )
  183. {
  184. idsButton = IDS_CHANGE_PASSWORD;
  185. }
  186. else
  187. {
  188. idsButton = IDS_CREATE_PASSWORD;
  189. }
  190. HWND hwndControl = GetDlgItem( IDC_CHANGE_PASSWORD );
  191. ASSERT( hwndControl );
  192. if ( hwndControl != NULL )
  193. {
  194. CString strButtonText;
  195. strButtonText.LoadString( idsButton );
  196. ::SetWindowText( hwndControl, strButtonText );
  197. }
  198. }