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.

128 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. /////////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Microsoft Windows
  5. // Copyright (C) Microsoft Corporation, 2000-2001.
  6. //
  7. // File: SaferEntryPropertySheet.cpp
  8. //
  9. // Contents: Implementation of CSaferEntryPropertySheet
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "stdafx.h"
  13. #include "SaferEntryPropertySheet.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. #define WM_SETOKDEFAULT WM_APP + 2001
  20. //////////////////////////////////////////////////////////////////////
  21. // Construction/Destruction
  22. //////////////////////////////////////////////////////////////////////
  23. CSaferEntryPropertySheet::CSaferEntryPropertySheet(UINT nIDCaption, CWnd *pParentWnd)
  24. : CPropertySheet (nIDCaption, pParentWnd)
  25. {
  26. }
  27. CSaferEntryPropertySheet::~CSaferEntryPropertySheet()
  28. {
  29. }
  30. BEGIN_MESSAGE_MAP(CSaferEntryPropertySheet, CPropertySheet)
  31. ON_MESSAGE(WM_HELP, OnHelp)
  32. ON_MESSAGE (WM_SETOKDEFAULT, OnSetOKDefault)
  33. END_MESSAGE_MAP()
  34. BOOL CSaferEntryPropertySheet::OnInitDialog()
  35. {
  36. _TRACE (1, L"Entering CSaferEntryPropertySheet::OnInitDialog ()\n");
  37. CPropertySheet::OnInitDialog();
  38. LONG dwStyle = GetWindowLong (m_hWnd, GWL_STYLE);
  39. dwStyle |= DS_CONTEXTHELP;
  40. SetWindowLong (m_hWnd, GWL_STYLE, dwStyle);
  41. dwStyle = GetWindowLong (m_hWnd, GWL_EXSTYLE);
  42. dwStyle |= WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP;
  43. SetWindowLong (m_hWnd, GWL_EXSTYLE, dwStyle);
  44. // Make the OK button the default
  45. PostMessage (WM_SETOKDEFAULT, 0, 0);
  46. _TRACE (-1, L"Leaving CSaferEntryPropertySheet::OnInitDialog ()\n");
  47. return TRUE; // return TRUE unless you set the focus to a control
  48. // EXCEPTION: OCX Property Pages should return FALSE
  49. }
  50. LRESULT CSaferEntryPropertySheet::OnSetOKDefault (WPARAM, LPARAM)
  51. {
  52. // Make the OK button the default
  53. SendMessage (DM_SETDEFID, MAKEWPARAM (IDOK, 0), 0);
  54. SendDlgItemMessage (IDOK, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0));
  55. SendDlgItemMessage (IDCANCEL, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0));
  56. return 0;
  57. }
  58. BOOL CSaferEntryPropertySheet::OnHelp(WPARAM /*wParam*/, LPARAM lParam)
  59. {
  60. _TRACE (1, L"Entering CSaferEntryPropertySheet::OnHelp\n");
  61. const LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  62. if (pHelpInfo && pHelpInfo->iContextType == HELPINFO_WINDOW)
  63. {
  64. DoContextHelp ((HWND) pHelpInfo->hItemHandle);
  65. }
  66. _TRACE (-1, L"Leaving CSaferEntryPropertySheet::OnHelp\n");
  67. return TRUE;
  68. }
  69. void CSaferEntryPropertySheet::DoContextHelp (HWND hWndControl)
  70. {
  71. _TRACE (1, L"Entering CSaferEntryPropertySheet::DoContextHelp\n");
  72. const int IDC_COMM_APPLYNOW = 12321;
  73. const int IDH_COMM_APPLYNOW = 28447;
  74. const DWORD aHelpIDs_PropSheet[]=
  75. {
  76. IDC_COMM_APPLYNOW, IDH_COMM_APPLYNOW,
  77. 0, 0
  78. };
  79. PWSTR pszHelpFile = 0;
  80. switch (::GetDlgCtrlID (hWndControl))
  81. {
  82. case IDC_COMM_APPLYNOW:
  83. pszHelpFile = const_cast <PWSTR> (WINDOWS_HELP);
  84. break;
  85. default:
  86. // Display context help for a control
  87. pszHelpFile = const_cast<PWSTR> ((PCWSTR)GetF1HelpFilename());
  88. break;
  89. }
  90. if ( !::WinHelp (
  91. hWndControl,
  92. pszHelpFile,
  93. HELP_WM_HELP,
  94. (DWORD_PTR) aHelpIDs_PropSheet) )
  95. {
  96. _TRACE (0, L"WinHelp () failed: 0x%x\n", GetLastError ());
  97. }
  98. _TRACE (-1, L"Leaving CSaferEntryPropertySheet::DoContextHelp\n");
  99. }