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.

208 lines
5.3 KiB

  1. // RemDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "RemDlg.h"
  5. #include "uihelp.h"
  6. #include <htmlhelp.h>
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CReminderDlg dialog
  14. CReminderDlg::CReminderDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CReminderDlg::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CReminderDlg)
  18. m_bMsgOnOff = FALSE;
  19. //}}AFX_DATA_INIT
  20. m_hKey = NULL;
  21. m_strRegValueName = _T("");
  22. }
  23. CReminderDlg::CReminderDlg(HKEY hKey, LPCTSTR pszRegValueName, CWnd* pParent /*=NULL*/)
  24. : CDialog(CReminderDlg::IDD, pParent)
  25. {
  26. m_bMsgOnOff = FALSE;
  27. m_hKey = hKey;
  28. m_strRegValueName = pszRegValueName;
  29. }
  30. void CReminderDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(CReminderDlg)
  34. DDX_Check(pDX, IDC_MSG_ONOFF, m_bMsgOnOff);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(CReminderDlg, CDialog)
  38. //{{AFX_MSG_MAP(CReminderDlg)
  39. ON_WM_CONTEXTMENU()
  40. ON_WM_HELPINFO()
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CReminderDlg message handlers
  45. void CReminderDlg::OnOK()
  46. {
  47. // TODO: Add extra validation here
  48. UpdateData(TRUE);
  49. if (m_bMsgOnOff && m_hKey && !m_strRegValueName.IsEmpty())
  50. {
  51. DWORD dwData = 1;
  52. (void)RegSetValueEx(m_hKey, m_strRegValueName, 0, REG_DWORD, (const BYTE *)&dwData, sizeof(DWORD));
  53. }
  54. CDialog::OnOK();
  55. }
  56. void CReminderDlg::OnContextMenu(CWnd* pWnd, CPoint point)
  57. {
  58. if (!pWnd)
  59. return;
  60. ::WinHelp(pWnd->GetSafeHwnd(),
  61. VSSUI_CTX_HELP_FILE,
  62. HELP_CONTEXTMENU,
  63. (DWORD_PTR)(PVOID)aMenuHelpIDsForReminder);
  64. }
  65. BOOL CReminderDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  66. {
  67. if (!pHelpInfo ||
  68. pHelpInfo->iContextType != HELPINFO_WINDOW ||
  69. pHelpInfo->iCtrlId < 0)
  70. return FALSE;
  71. ::WinHelp((HWND)pHelpInfo->hItemHandle,
  72. VSSUI_CTX_HELP_FILE,
  73. HELP_WM_HELP,
  74. (DWORD_PTR)(PVOID)aMenuHelpIDsForReminder);
  75. return TRUE;
  76. }
  77. BOOL CReminderDlg::OnInitDialog()
  78. {
  79. CDialog::OnInitDialog();
  80. HICON hIcon = ::LoadIcon(NULL, IDI_EXCLAMATION);
  81. ((CStatic*)GetDlgItem(IDC_REMINDER_ICON))->SetIcon(hIcon);
  82. return TRUE; // return TRUE unless you set the focus to a control
  83. // EXCEPTION: OCX Property Pages should return FALSE
  84. }
  85. /////////////////////////////////////////////////////////////////////////////
  86. // CReminderDlgEx dialog
  87. CReminderDlgEx::CReminderDlgEx(CWnd* pParent /*=NULL*/)
  88. : CDialog(CReminderDlgEx::IDD, pParent)
  89. {
  90. //{{AFX_DATA_INIT(CReminderDlgEx)
  91. m_bMsgOnOff = FALSE;
  92. //}}AFX_DATA_INIT
  93. m_hKey = NULL;
  94. m_strRegValueName = _T("");
  95. }
  96. CReminderDlgEx::CReminderDlgEx(HKEY hKey, LPCTSTR pszRegValueName, CWnd* pParent /*=NULL*/)
  97. : CDialog(CReminderDlgEx::IDD, pParent)
  98. {
  99. m_bMsgOnOff = FALSE;
  100. m_hKey = hKey;
  101. m_strRegValueName = pszRegValueName;
  102. }
  103. void CReminderDlgEx::DoDataExchange(CDataExchange* pDX)
  104. {
  105. CDialog::DoDataExchange(pDX);
  106. //{{AFX_DATA_MAP(CReminderDlgEx)
  107. DDX_Check(pDX, IDC_MSG_ONOFF, m_bMsgOnOff);
  108. //}}AFX_DATA_MAP
  109. }
  110. BEGIN_MESSAGE_MAP(CReminderDlgEx, CDialog)
  111. //{{AFX_MSG_MAP(CReminderDlgEx)
  112. ON_WM_CONTEXTMENU()
  113. ON_WM_HELPINFO()
  114. ON_NOTIFY(NM_CLICK, IDC_MESSAGE, OnHelpLink)
  115. ON_NOTIFY(NM_RETURN, IDC_MESSAGE, OnHelpLink)
  116. //}}AFX_MSG_MAP
  117. END_MESSAGE_MAP()
  118. /////////////////////////////////////////////////////////////////////////////
  119. // CReminderDlgEx message handlers
  120. void CReminderDlgEx::OnOK()
  121. {
  122. // TODO: Add extra validation here
  123. UpdateData(TRUE);
  124. if (m_bMsgOnOff && m_hKey && !m_strRegValueName.IsEmpty())
  125. {
  126. DWORD dwData = 1;
  127. (void)RegSetValueEx(m_hKey, m_strRegValueName, 0, REG_DWORD, (const BYTE *)&dwData, sizeof(DWORD));
  128. }
  129. CDialog::OnOK();
  130. }
  131. void CReminderDlgEx::OnContextMenu(CWnd* pWnd, CPoint point)
  132. {
  133. if (!pWnd)
  134. return;
  135. ::WinHelp(pWnd->GetSafeHwnd(),
  136. VSSUI_CTX_HELP_FILE,
  137. HELP_CONTEXTMENU,
  138. (DWORD_PTR)(PVOID)aMenuHelpIDsForReminder);
  139. }
  140. BOOL CReminderDlgEx::OnHelpInfo(HELPINFO* pHelpInfo)
  141. {
  142. if (!pHelpInfo ||
  143. pHelpInfo->iContextType != HELPINFO_WINDOW ||
  144. pHelpInfo->iCtrlId < 0)
  145. return FALSE;
  146. ::WinHelp((HWND)pHelpInfo->hItemHandle,
  147. VSSUI_CTX_HELP_FILE,
  148. HELP_WM_HELP,
  149. (DWORD_PTR)(PVOID)aMenuHelpIDsForReminder);
  150. return TRUE;
  151. }
  152. void CReminderDlgEx::OnHelpLink(NMHDR* pNMHDR, LRESULT* pResult)
  153. {
  154. CWaitCursor wait;
  155. ::HtmlHelp(0, _T("timewarp.chm"), HH_DISPLAY_TOPIC, (DWORD_PTR)(_T("best_practices_snapshot.htm")));
  156. *pResult = 0;
  157. }
  158. BOOL CReminderDlgEx::OnInitDialog()
  159. {
  160. CDialog::OnInitDialog();
  161. HICON hIcon = ::LoadIcon(NULL, IDI_INFORMATION);
  162. ((CStatic*)GetDlgItem(IDC_REMINDER_ICON))->SetIcon(hIcon);
  163. return TRUE; // return TRUE unless you set the focus to a control
  164. // EXCEPTION: OCX Property Pages should return FALSE
  165. }