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.

199 lines
5.0 KiB

  1. // HelpPropertyPage.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. // CHelpPropertyPage property page
  11. CHelpPropertyPage::CHelpPropertyPage(UINT uIDD) :
  12. CAutoDeletePropPage(uIDD),
  13. m_hWndWhatsThis (0)
  14. {
  15. //{{AFX_DATA_INIT(CHelpPropertyPage)
  16. // NOTE: the ClassWizard will add member initialization here
  17. //}}AFX_DATA_INIT
  18. }
  19. CHelpPropertyPage::~CHelpPropertyPage()
  20. {
  21. }
  22. void CHelpPropertyPage::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CAutoDeletePropPage::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CHelpPropertyPage)
  26. // NOTE: the ClassWizard will add DDX and DDV calls here
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CHelpPropertyPage, CAutoDeletePropPage)
  30. //{{AFX_MSG_MAP(CHelpPropertyPage)
  31. ON_WM_CONTEXTMENU()
  32. //}}AFX_MSG_MAP
  33. ON_MESSAGE(WM_HELP, OnHelp)
  34. ON_COMMAND(IDM_WHATS_THIS, OnWhatsThis)
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CHelpPropertyPage message handlers
  38. void CHelpPropertyPage::OnWhatsThis()
  39. {
  40. _TRACE (1, L"Entering CHelpPropertyPage::OnWhatsThis\n");
  41. // Display context help for a control
  42. if ( m_hWndWhatsThis )
  43. {
  44. DoContextHelp (m_hWndWhatsThis);
  45. }
  46. _TRACE (-1, L"Leaving CHelpPropertyPage::OnWhatsThis\n");
  47. }
  48. BOOL CHelpPropertyPage::OnHelp(WPARAM /*wParam*/, LPARAM lParam)
  49. {
  50. _TRACE (1, L"Entering CHelpPropertyPage::OnHelp\n");
  51. const LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  52. if (pHelpInfo && pHelpInfo->iContextType == HELPINFO_WINDOW)
  53. {
  54. // Display context help for a control
  55. DoContextHelp ((HWND) pHelpInfo->hItemHandle);
  56. }
  57. _TRACE (-1, L"Leaving CHelpPropertyPage::OnHelp\n");
  58. return TRUE;
  59. }
  60. void CHelpPropertyPage::DoContextHelp (HWND /*hWndControl*/)
  61. {
  62. }
  63. void CHelpPropertyPage::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
  64. {
  65. // point is in screen coordinates
  66. _TRACE (1, L"Entering CHelpPropertyPage::OnContextMenu\n");
  67. CMenu bar;
  68. if ( bar.LoadMenu(IDR_WHATS_THIS_CONTEXT_MENU1) )
  69. {
  70. CMenu& popup = *bar.GetSubMenu (0);
  71. ASSERT(popup.m_hMenu);
  72. if ( popup.TrackPopupMenu (TPM_RIGHTBUTTON | TPM_LEFTBUTTON,
  73. point.x, // in screen coordinates
  74. point.y, // in screen coordinates
  75. this) ) // route commands through main window
  76. {
  77. m_hWndWhatsThis = 0;
  78. ScreenToClient (&point);
  79. CWnd* pChild = ChildWindowFromPoint (
  80. point, // in client coordinates
  81. CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
  82. if ( pChild )
  83. m_hWndWhatsThis = pChild->m_hWnd;
  84. }
  85. }
  86. _TRACE (-1, L"Leaving CHelpPropertyPage::OnContextMenu\n");
  87. }
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CHelpDialog property page
  90. CHelpDialog::CHelpDialog(UINT uIDD, CWnd* pParentWnd) :
  91. CDialog(uIDD, pParentWnd),
  92. m_hWndWhatsThis (0)
  93. {
  94. //{{AFX_DATA_INIT(CHelpDialog)
  95. // NOTE: the ClassWizard will add member initialization here
  96. //}}AFX_DATA_INIT
  97. }
  98. CHelpDialog::~CHelpDialog()
  99. {
  100. }
  101. void CHelpDialog::DoDataExchange(CDataExchange* pDX)
  102. {
  103. CDialog::DoDataExchange(pDX);
  104. //{{AFX_DATA_MAP(CHelpDialog)
  105. // NOTE: the ClassWizard will add DDX and DDV calls here
  106. //}}AFX_DATA_MAP
  107. }
  108. BEGIN_MESSAGE_MAP(CHelpDialog, CDialog)
  109. //{{AFX_MSG_MAP(CHelpDialog)
  110. ON_WM_CONTEXTMENU()
  111. //}}AFX_MSG_MAP
  112. ON_MESSAGE(WM_HELP, OnHelp)
  113. ON_COMMAND(IDM_WHATS_THIS, OnWhatsThis)
  114. END_MESSAGE_MAP()
  115. /////////////////////////////////////////////////////////////////////////////
  116. // CHelpDialog message handlers
  117. void CHelpDialog::OnWhatsThis()
  118. {
  119. _TRACE (1, L"Entering CHelpDialog::OnWhatsThis\n");
  120. // Display context help for a control
  121. if ( m_hWndWhatsThis )
  122. {
  123. DoContextHelp (m_hWndWhatsThis);
  124. }
  125. _TRACE (-1, L"Leaving CHelpDialog::OnWhatsThis\n");
  126. }
  127. BOOL CHelpDialog::OnHelp(WPARAM /*wParam*/, LPARAM lParam)
  128. {
  129. _TRACE (1, L"Entering CHelpDialog::OnHelp\n");
  130. const LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  131. if (pHelpInfo && pHelpInfo->iContextType == HELPINFO_WINDOW)
  132. {
  133. // Display context help for a control
  134. DoContextHelp ((HWND) pHelpInfo->hItemHandle);
  135. }
  136. _TRACE (-1, L"Leaving CHelpDialog::OnHelp\n");
  137. return TRUE;
  138. }
  139. void CHelpDialog::DoContextHelp (HWND /*hWndControl*/)
  140. {
  141. }
  142. void CHelpDialog::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
  143. {
  144. // point is in screen coordinates
  145. _TRACE (1, L"Entering CHelpDialog::OnContextMenu\n");
  146. CMenu bar;
  147. if ( bar.LoadMenu(IDR_WHATS_THIS_CONTEXT_MENU1) )
  148. {
  149. CMenu& popup = *bar.GetSubMenu (0);
  150. ASSERT(popup.m_hMenu);
  151. if ( popup.TrackPopupMenu (TPM_RIGHTBUTTON | TPM_LEFTBUTTON,
  152. point.x, // in screen coordinates
  153. point.y, // in screen coordinates
  154. this) ) // route commands through main window
  155. {
  156. m_hWndWhatsThis = 0;
  157. ScreenToClient (&point);
  158. CWnd* pChild = ChildWindowFromPoint (
  159. point, // in client coordinates
  160. CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
  161. if ( pChild )
  162. m_hWndWhatsThis = pChild->m_hWnd;
  163. }
  164. }
  165. _TRACE (-1, L"Leaving CHelpDialog::OnContextMenu\n");
  166. }