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.

200 lines
5.3 KiB

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