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.

138 lines
3.8 KiB

  1. // WarningDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #ifdef _DEBUG
  5. #define new DEBUG_NEW
  6. #undef THIS_FILE
  7. static char THIS_FILE[] = __FILE__;
  8. #endif
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CWarningDlg dialog
  11. CWarningDlg::CWarningDlg(UINT nWarningIds, UINT nTitleIds /*= 0*/, CWnd* pParent /*=NULL*/)
  12. : CDialog(CWarningDlg::IDD, pParent),
  13. m_nWarningIds( nWarningIds ),
  14. m_nTitleIds( nTitleIds )
  15. {
  16. //{{AFX_DATA_INIT(CWarningDlg)
  17. //}}AFX_DATA_INIT
  18. m_sWarning = _T("");
  19. m_bEnableShowAgainCheckbox = FALSE; // default is hide checkbox
  20. m_bDoNotShowAgainCheck = FALSE; // default is show checkbox again
  21. }
  22. CWarningDlg::CWarningDlg(LPCTSTR szWarningMessage, UINT nTitleIds /*= 0*/, CWnd* pParent /*=NULL*/)
  23. : CDialog(CWarningDlg::IDD, pParent),
  24. m_nWarningIds( 0 ),
  25. m_nTitleIds( nTitleIds )
  26. {
  27. //{{AFX_DATA_INIT(CWarningDlg)
  28. m_sWarning = _T("");
  29. //}}AFX_DATA_INIT
  30. m_bEnableShowAgainCheckbox = FALSE; // default is hide checkbox
  31. m_bDoNotShowAgainCheck = FALSE; // default is show checkbox again
  32. m_sWarning = szWarningMessage;
  33. }
  34. void CWarningDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CWarningDlg)
  38. DDX_Control(pDX, IDC_EDIT_EXPLANATION, m_editWarning);
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(CWarningDlg, CDialog)
  42. //{{AFX_MSG_MAP(CWarningDlg)
  43. ON_BN_CLICKED(IDYES, OnYes)
  44. ON_BN_CLICKED(IDNO, OnNo)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CWarningDlg Operations
  49. void CWarningDlg::EnableDoNotShowAgainCheck( BOOL bEnable )
  50. {
  51. m_bEnableShowAgainCheckbox = bEnable;
  52. }
  53. BOOL CWarningDlg::GetDoNotShowAgainCheck()
  54. {
  55. if (m_bEnableShowAgainCheckbox)
  56. return m_bDoNotShowAgainCheck;
  57. return FALSE;
  58. }
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CWarningDlg message handlers
  61. BOOL CWarningDlg::OnInitDialog()
  62. {
  63. // Load the warning string for display in the dialog
  64. // if m_nWarningIds == 0, that means we already load
  65. // the message string in constructor
  66. if (m_nWarningIds)
  67. {
  68. m_sWarning.FormatMessage( m_nWarningIds );
  69. }
  70. GetDlgItem(IDC_EDIT_EXPLANATION)->SetWindowText(m_sWarning);
  71. // Load the title, if any
  72. if (m_nTitleIds)
  73. {
  74. try { m_sTitle.LoadString( m_nTitleIds ); }
  75. catch( CMemoryException *pe )
  76. {
  77. ASSERT( FALSE );
  78. pe->Delete();
  79. m_sTitle.Empty();
  80. }
  81. if (!m_sTitle.IsEmpty())
  82. {
  83. SetWindowText( m_sTitle );
  84. }
  85. }
  86. // Determine whether the "Do not show this again" checkbox should be displayed.
  87. SAFE_SHOWWINDOW( IDC_CHECKNOTAGAIN, m_bEnableShowAgainCheckbox ? SW_SHOW : SW_HIDE );
  88. CDialog::OnInitDialog();
  89. // default to NO since user is doing something questionable
  90. // which requires us to ask if its really OK.
  91. GetDlgItem(IDNO)->SetFocus();
  92. SetDefID( IDNO );
  93. return 0; // return TRUE unless you set the focus to a control
  94. // EXCEPTION: OCX Property Pages should return FALSE
  95. }
  96. void CWarningDlg::OnYes()
  97. {
  98. if (m_bEnableShowAgainCheckbox)
  99. {
  100. if (1 == ((CButton*)GetDlgItem( IDC_CHECKNOTAGAIN ))->GetCheck())
  101. m_bDoNotShowAgainCheck = TRUE;
  102. else
  103. m_bDoNotShowAgainCheck = FALSE;
  104. }
  105. EndDialog( IDYES );
  106. }
  107. void CWarningDlg::OnNo()
  108. {
  109. if (m_bEnableShowAgainCheckbox)
  110. {
  111. if (1 == ((CButton*)GetDlgItem( IDC_CHECKNOTAGAIN ))->GetCheck())
  112. m_bDoNotShowAgainCheck = TRUE;
  113. else
  114. m_bDoNotShowAgainCheck = FALSE;
  115. }
  116. EndDialog( IDNO );
  117. }