PropertiesDialog.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:18k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // PropertiesDialog.cpp : implementation file
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "ToolTipContext.h"
  22. #include "PropertiesDialog.h"
  23. #include "MainFrm.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CPropertiesDialog dialog
  31. CPropertiesDialog::CPropertiesDialog(CWnd* pParent /*=NULL*/)
  32. : CDialog(CPropertiesDialog::IDD, pParent)
  33. {
  34. //{{AFX_DATA_INIT(CPropertiesDialog)
  35. m_bPopupBarTips = TRUE;
  36. m_bShowDescription = TRUE;
  37. m_nToolTipStyle = 1;
  38. m_bToolBarScreenTips = TRUE;
  39. m_bToolBarAccelTips = FALSE;
  40. m_bShowDescription = TRUE;
  41. m_bShowIcons = FALSE;
  42. m_bShowShadow = FALSE;
  43. m_bShowOfficeBorder = TRUE;
  44. //}}AFX_DATA_INIT
  45. }
  46. void CPropertiesDialog::DoDataExchange(CDataExchange* pDX)
  47. {
  48. CDialog::DoDataExchange(pDX);
  49. //{{AFX_DATA_MAP(CPropertiesDialog)
  50. DDX_Check(pDX, IDC_CHECK_POPUPBARTIPS, m_bPopupBarTips);
  51. DDX_Check(pDX, IDC_CHECK_SHOWDESCRIPTION, m_bShowDescription);
  52. DDX_Radio(pDX, IDC_RADIO_TOOLTIPSTYLE, m_nToolTipStyle);
  53. DDX_Check(pDX, IDC_CHECK_SHOWTIPS, m_bToolBarScreenTips);
  54. DDX_Check(pDX, IDC_CHECK_SHOWSHORTCUTS, m_bToolBarAccelTips);
  55. DDX_Check(pDX, IDC_CHECK_SHOWIMAGE, m_bShowIcons);
  56. DDX_Check(pDX, IDC_CHECK_SHOWSHADOW, m_bShowShadow);
  57. DDX_Check(pDX, IDC_CHECK_SHOWBORDER, m_bShowOfficeBorder);
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(CPropertiesDialog, CDialog)
  61. //{{AFX_MSG_MAP(CPropertiesDialog)
  62. ON_BN_CLICKED(IDC_CHECK_POPUPBARTIPS, OnCheckPopupBarTips)
  63. ON_BN_CLICKED(IDC_CHECK_SHOWDESCRIPTION, OnCheckShowDescription)
  64. ON_BN_CLICKED(IDC_CHECK_SHOWTIPS, OnCheckShowTips)
  65. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE, OnRadioTooltipStyle)
  66. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE_BALLOON, OnRadioTooltipStyle)
  67. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE_OFFICE, OnRadioTooltipStyle)
  68. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE_RTF, OnRadioTooltipStyle)
  69. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE_LUNA, OnRadioTooltipStyle)
  70. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE_OFFICE2007, OnRadioTooltipStyle)
  71. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE_HTML, OnRadioTooltipStyle)
  72. ON_BN_CLICKED(IDC_RADIO_TOOLTIPSTYLE_MARKUP, OnRadioTooltipStyle)
  73. ON_BN_CLICKED(IDC_CHECK_SHOWIMAGE, OnCheckShowIcons)
  74. ON_BN_CLICKED(IDC_CHECK_SHOWSHADOW, OnCheckShowShadow)
  75. ON_BN_CLICKED(IDC_CHECK_SHOWBORDER, OnCheckShowOfficeBorder)
  76. ON_BN_CLICKED(IDC_CHECK_SHOWSHORTCUTS, OnCheckShowshortcuts)
  77. ON_NOTIFY_EX_RANGE(TTN_NEEDTEXT, 0, 0xFFFF, OnToolTipText)
  78. //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80. /////////////////////////////////////////////////////////////////////////////
  81. // CPropertiesDialog message handlers
  82. BOOL CPropertiesDialog::OnInitDialog() 
  83. {
  84. CDialog::OnInitDialog();
  85. BOOL bBalloonStyleSupported = m_moduleContext.IsBalloonStyleSupported();
  86. if (!bBalloonStyleSupported)
  87. {
  88. m_nToolTipStyle = 0;
  89. GetDlgItem(IDC_RADIO_TOOLTIPSTYLE_BALLOON)->EnableWindow(FALSE);
  90. UpdateData(FALSE);
  91. }
  92. EnableToolTips();
  93. m_moduleContext.SetModuleToolTipContext();
  94. m_moduleContext.SetStyle(xtpToolTipMarkup);
  95. m_moduleContext.SetMaxTipWidth(200);
  96. UpdateControls();
  97. return TRUE;  // return TRUE unless you set the focus to a control
  98.               // EXCEPTION: OCX Property Pages should return FALSE
  99. }
  100. CString CreateHTMLTool(LPCTSTR strCaption, LPCTSTR strDesc)
  101. {
  102. TCHAR lpszModule[_MAX_PATH];
  103. GetModuleFileName(AfxGetInstanceHandle(), lpszModule, _MAX_PATH);
  104. CString strHTML;
  105. strHTML.Format(_T("<table cellspacing=4 cellpadding=0 border=0><tr><td><b>%s</b></td></tr>")
  106. _T("<tr><td><table cellspacing=4 cellpadding=0 border=0><tr><td width=6></td><td>%s</td></tr></table></td></tr>")
  107.         _T("<tr><td><table width=100%% cellspacing=0 cellpadding=0 border=0 bgcolor=gray><tr><td></td></tr></table></td></tr>")
  108. _T("<tr><td><table><tr><td><img width=16 height=16 src=res://%s/Help.gif></td>")
  109. _T("<td><b>Press F1 for more help</b></td></tr></table></td></tr></table>"),
  110. strCaption, strDesc, (LPCTSTR)lpszModule);
  111. return strHTML;
  112. }
  113. CString CreateMarkupTool(LPCTSTR strCaption, LPCTSTR strDesc)
  114. {
  115. TCHAR lpszModule[_MAX_PATH];
  116. GetModuleFileName(AfxGetInstanceHandle(), lpszModule, _MAX_PATH);
  117. CString strHTML;
  118. strHTML.Format(
  119. _T("<StackPanel Margin='1' MaxWidth='200'>")
  120. _T("<TextBlock Padding='1, 3, 1, 3' FontWeight='Bold'>%s</TextBlock>")
  121. _T("<TextBlock Padding='9, 6, 30, 7' TextWrapping='Wrap'>%s</TextBlock>")
  122. _T("<Border Height='1' Background='#9ebbdd' />")
  123. _T("<Border Height='1' Background='White' />")
  124. _T("<StackPanel Margin='1, 7, 0, 3' Orientation='Horizontal'>")
  125. _T("<Image Source='res://Help.ico'/><TextBlock Margin='7, 0, 0, 0' VerticalAlignment='Center' FontWeight='Bold'>Press F1 for more help.</TextBlock>")
  126. _T("</StackPanel>")
  127. _T("</StackPanel>"),
  128. strCaption, strDesc, (LPCTSTR)lpszModule);
  129. return strHTML;
  130. }
  131. void CPropertiesDialog::UpdateCommandBarToolTips()
  132. {
  133. CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
  134. CXTPCommandBars* pCommandBars = pMainFrame->GetCommandBars();
  135. if (pCommandBars->GetToolTipContext()->GetStyle() == xtpToolTipMarkup)
  136. {
  137. pCommandBars->GetActions()->FindAction(ID_FILE_NEW)->SetTooltip(_T("<TextBlock FontWeight='Bold' Text='New'/>"));
  138. pCommandBars->GetActions()->FindAction(ID_FILE_OPEN)->SetTooltip(_T("<TextBlock Foreground='Red' Text='Open'/>"));
  139. pCommandBars->GetActions()->FindAction(ID_FILE_SAVE)->SetTooltip(_T("<TextBlock FontStyle='Italic' TextDecorations='Underline' Text='Save'/>"));
  140. pCommandBars->GetActions()->FindAction(ID_EDIT_CUT)->SetTooltip(
  141. CreateMarkupTool(_T("Cut"), _T("Cut the selection and <Underline>put</Underline> it on the Clipboard")));
  142. pCommandBars->GetActions()->FindAction(ID_EDIT_COPY)->SetTooltip(
  143. CreateMarkupTool(_T("Copy"), _T("Copy the selection and put it on the Clipboard")));
  144. pCommandBars->GetActions()->FindAction(ID_EDIT_PASTE)->SetTooltip(
  145. CreateMarkupTool(_T("Paste"), _T("Insert Clipboard contents")));
  146. pCommandBars->GetActions()->FindAction(ID_FILE_PRINT)->SetTooltip(
  147. CreateMarkupTool(_T("Print"), _T("Print the active document")));
  148. pCommandBars->GetActions()->FindAction(ID_APP_ABOUT)->SetTooltip(
  149. CreateMarkupTool(_T("About"),_T("Display program information, version number and copyright")));
  150. }
  151. else if (pCommandBars->GetToolTipContext()->GetStyle() == xtpToolTipHTML)
  152. {
  153. pCommandBars->GetActions()->FindAction(ID_FILE_NEW)->SetTooltip(_T("<b>New<b>"));
  154. pCommandBars->GetActions()->FindAction(ID_FILE_OPEN)->SetTooltip(_T("<font color=red>Open</font>"));
  155. pCommandBars->GetActions()->FindAction(ID_FILE_SAVE)->SetTooltip(_T("<i><u>Save</u></i>"));
  156. pCommandBars->GetActions()->FindAction(ID_EDIT_CUT)->SetTooltip(
  157. CreateHTMLTool(_T("Cut"), _T("Cut the selection and put it on the Clipboard")));
  158. pCommandBars->GetActions()->FindAction(ID_EDIT_COPY)->SetTooltip(
  159. CreateHTMLTool(_T("Copy"), _T("Copy the selection and put it on the Clipboard")));
  160. pCommandBars->GetActions()->FindAction(ID_EDIT_PASTE)->SetTooltip(
  161. CreateHTMLTool(_T("Paste"), _T("Insert Clipboard contents")));
  162. pCommandBars->GetActions()->FindAction(ID_FILE_PRINT)->SetTooltip(
  163. CreateHTMLTool(_T("Print"), _T("Print the active document")));
  164. pCommandBars->GetActions()->FindAction(ID_APP_ABOUT)->SetTooltip(
  165. CreateHTMLTool(_T("About"),_T("Display program information, version number and copyright")));
  166. }
  167. else if (pCommandBars->GetToolTipContext()->GetStyle() == xtpToolTipRTF)
  168. {
  169.             pCommandBars->GetActions()->FindAction(ID_FILE_NEW)->SetTooltip(
  170.                 _T("{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fscript\fprq2\fcharset0 Lucida Handwriting;}{\f1\fnil\fcharset0 Courier New;}}{\colortbl ;\red0\green0\blue0;}\viewkind4\uc1\pard\ltrpar\cf1\lang1033\f0\fs28 Create a \b new\b0  document\cf0\f1\fs20\par}"));
  171.             pCommandBars->GetActions()->FindAction(ID_FILE_OPEN)->SetTooltip(
  172.                 _T("{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fnil\fcharset0 Courier New;}{\f1\fmodern\fprq1\fcharset0 Courier New;}}{\colortbl ;\red255\green0\blue0;}\viewkind4\uc1\pard\ltrpar\lang1033\f0\fs20 Open an \cf1\ul\i\f1 existing\cf0\ulnone\i0\f0  document\par}"));
  173.             pCommandBars->GetActions()->FindAction(ID_FILE_SAVE)->SetTooltip(
  174.                 _T("{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\fnil\fcharset0 Courier New;}}{\colortbl ;\red0\green0\blue255;}\viewkind4\uc1\pard\ltrpar\cf1\lang1033\b\i\f0\fs20 Save the active document\cf0\b0\i0\f1\par}"));
  175.             pCommandBars->GetActions()->FindAction(ID_EDIT_CUT)->SetTooltip(
  176.                 _T("{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fmodern\fprq1\fcharset0 Courier New;}{\f1\fnil\fcharset0 Courier New;}{\f2\fnil\fcharset2 Symbol;}}\viewkind4\uc1\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\ltrpar\fi-720\li720\lang1033\f0\fs20 Cuts the selection \par{\pntext\f2\'B7\tab}Then puts it on the Clipboard\par{\pntext\f2\'B7\tab}The \ul\b Paste\ulnone\b0  command can then be used to retrieve the text\f1\par}"));
  177.             pCommandBars->GetActions()->FindAction(ID_EDIT_COPY)->SetTooltip(
  178.                 _T("{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fdecor\fprq2\fcharset0 Ravie;}{\f1\fnil\fcharset0 Courier New;}{\f2\fnil\fcharset2 Symbol;}}{\colortbl ;\red0\green0\blue255;\red255\green0\blue0;\red0\green255\blue0;\red0\green128\blue0;\red255\green0\blue255;\red255\green255\blue0;}\viewkind4\uc1\pard\ltrpar\lang1033\f0\fs20 Clipboard Actions:\par\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\ltrpar\fi-720\li720\cf1 Copy \cf2 the\cf0  \cf3 selection \cf0\par\pard{\pntext\f2\'B7\tab}{\*\pn\pnlvlblt\pnf2\pnindent0{\pntxtb\'B7}}\ltrpar\fi-720\li720\tx3780\cf4 Then \cf5 put \cf1 it \cf6 on \cf3 the \cf2\ul\b Clipboard\cf0\ulnone\b0\f1\par}"));
  179.             pCommandBars->GetActions()->FindAction(ID_EDIT_PASTE)->SetTooltip(
  180.                 _T("{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Courier New;}}\viewkind4\uc1\pard\ltrpar\lang1033\f0\fs36 Insert\fs20  \fs26 Clipboard\fs20  \fs16 contents\f1\fs20\par}"));
  181.             pCommandBars->GetActions()->FindAction(ID_FILE_PRINT)->SetTooltip(
  182.                 _T("{\rtf {\b Print} the {\i\ul active} document}"));
  183.             pCommandBars->GetActions()->FindAction(ID_APP_ABOUT)->SetTooltip(
  184.                 _T("{\rtf1\fbidis\ansi\ansicpg1256\deff0\deflang1025{\fonttbl{\f0\fnil\fcharset0 Courier New;}}{\colortbl ;\red0\green255\blue0;\red0\green0\blue255;\red0\green255\blue255;\red255\green255\blue0;\red128\green128\blue128;\red255\green0\blue255;\red0\green128\blue0;}\viewkind4\uc1\pard\ltrpar\cf1\lang1033\f0\fs20 Display\cf0  \cf2 help\cf0  \cf3 for \cf4 current \cf5 task \cf6 or \cf7 command\cf0\par}"));
  185. }
  186. else
  187. {
  188. pCommandBars->GetActions()->FindAction(ID_FILE_NEW)->SetTooltip(_T("New"));
  189. pCommandBars->GetActions()->FindAction(ID_FILE_OPEN)->SetTooltip(_T("Open"));
  190. pCommandBars->GetActions()->FindAction(ID_FILE_SAVE)->SetTooltip(_T("Save"));
  191. pCommandBars->GetActions()->FindAction(ID_EDIT_CUT)->SetTooltip(_T("Cut"));
  192. pCommandBars->GetActions()->FindAction(ID_EDIT_COPY)->SetTooltip(_T("Copy"));
  193. pCommandBars->GetActions()->FindAction(ID_EDIT_PASTE)->SetTooltip(_T("Paste"));
  194. pCommandBars->GetActions()->FindAction(ID_FILE_PRINT)->SetTooltip(_T("Print"));
  195. pCommandBars->GetActions()->FindAction(ID_APP_ABOUT)->SetTooltip(_T("About"));
  196. }
  197. void CPropertiesDialog::OnCheckPopupBarTips() 
  198. {
  199. UpdateData();
  200. ((CXTPMDIFrameWnd*) AfxGetMainWnd())->GetCommandBars()->
  201. GetCommandBarsOptions()->bShowPopupBarToolTips = m_bPopupBarTips;
  202. }
  203. CXTPToolTipContext* CPropertiesDialog::GetToolTipContext()
  204. {
  205. return ((CXTPMDIFrameWnd*) GetTopLevelFrame())->GetCommandBars()->GetToolTipContext();
  206. }
  207. void CPropertiesDialog::OnCheckShowDescription() 
  208. {
  209. UpdateData();
  210. ((CXTPMDIFrameWnd*) AfxGetMainWnd())->GetCommandBars()->GetToolTipContext()->
  211. ShowTitleAndDescription(m_bShowDescription);
  212. }
  213. void CPropertiesDialog::UpdateControls()
  214. {
  215. BOOL bSystemStyle = m_nToolTipStyle == xtpToolTipStandard || m_nToolTipStyle == xtpToolTipBalloon;
  216. GetDlgItem(IDC_CHECK_SHOWSHADOW)->EnableWindow(!bSystemStyle);
  217. GetDlgItem(IDC_CHECK_SHOWIMAGE)->EnableWindow(!bSystemStyle && (m_nToolTipStyle != xtpToolTipRTF && m_nToolTipStyle != xtpToolTipHTML && m_nToolTipStyle != xtpToolTipMarkup));
  218. GetDlgItem(IDC_CHECK_SHOWBORDER)->EnableWindow(!bSystemStyle);
  219. GetDlgItem(IDC_CHECK_SHOWDESCRIPTION)->EnableWindow((m_nToolTipStyle != xtpToolTipRTF && m_nToolTipStyle != xtpToolTipHTML && m_nToolTipStyle != xtpToolTipMarkup));
  220. m_bShowOfficeBorder = GetToolTipContext()->GetControlStyle() & XTP_TTS_OFFICEFRAME ? 1 : 0;
  221. m_bShowShadow = (GetToolTipContext()->GetControlStyle() & XTP_TTS_NOSHADOW) == 0;
  222. UpdateData(FALSE);
  223. }
  224. void CPropertiesDialog::OnRadioTooltipStyle() 
  225. {
  226. UpdateData();
  227. CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
  228. pMainFrame->GetCommandBars()->GetToolTipContext()->
  229. SetStyle((XTPToolTipStyle)m_nToolTipStyle);
  230. pMainFrame->m_wndClient.GetToolTipContext()->
  231. SetStyle((XTPToolTipStyle)m_nToolTipStyle);
  232. if (m_nToolTipStyle == xtpToolTipMarkup)
  233. {
  234. pMainFrame->GetCommandBars()->GetToolTipContext()->ModifyToolTipStyle(0, XTP_TTS_OFFICE2007FRAME);
  235. }
  236. UpdateControls();
  237. UpdateCommandBarToolTips();
  238. }
  239. void CPropertiesDialog::OnCheckShowIcons()
  240. {
  241. UpdateData();
  242. CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
  243. pMainFrame->GetCommandBars()->GetToolTipContext()->ShowImage(m_bShowIcons);
  244. pMainFrame->m_wndClient.GetToolTipContext()->ShowImage(m_bShowIcons);
  245. }
  246. void CPropertiesDialog::ToggleStyle(DWORD dwStyle)
  247. {
  248. CXTPToolTipContext* pToolTipContext = 
  249. ((CXTPMDIFrameWnd*) AfxGetMainWnd())->GetCommandBars()->GetToolTipContext();
  250. if (pToolTipContext->GetControlStyle() & dwStyle)
  251. pToolTipContext->ModifyToolTipStyle(dwStyle, 0);
  252. else
  253. pToolTipContext->ModifyToolTipStyle(0, dwStyle);
  254. }
  255. void CPropertiesDialog::OnCheckShowShadow()
  256. {
  257. UpdateData();
  258. ToggleStyle(XTP_TTS_NOSHADOW);
  259. }
  260. void CPropertiesDialog::OnCheckShowOfficeBorder()
  261. {
  262. UpdateData();
  263. ToggleStyle(XTP_TTS_OFFICEFRAME);
  264. }
  265. void CPropertiesDialog::OnCheckShowTips() 
  266. {
  267. UpdateData();
  268. ((CXTPMDIFrameWnd*) AfxGetMainWnd())->GetCommandBars()->
  269. GetCommandBarsOptions()->bToolBarScreenTips = m_bToolBarScreenTips;
  270. GetDlgItem(IDC_CHECK_SHOWSHORTCUTS)->EnableWindow(m_bToolBarScreenTips);
  271. GetDlgItem(IDC_CHECK_POPUPBARTIPS)->EnableWindow(m_bToolBarScreenTips);
  272. }
  273. void CPropertiesDialog::OnCheckShowshortcuts() 
  274. {
  275. UpdateData();
  276. ((CXTPMDIFrameWnd*) AfxGetMainWnd())->GetCommandBars()->
  277. GetCommandBarsOptions()->bToolBarAccelTips = m_bToolBarAccelTips;
  278. }
  279. BOOL CPropertiesDialog::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
  280. {
  281. ASSERT(pNMHDR->code == TTN_NEEDTEXT);
  282. TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
  283. if (!(pTTT->uFlags & TTF_IDISHWND))
  284. return FALSE;
  285. UINT_PTR hWnd = pNMHDR->idFrom;
  286. // idFrom is actually the HWND of the tool
  287. UINT nID = (UINT)(WORD)::GetDlgCtrlID((HWND)hWnd);
  288. pTTT->lpszText = MAKEINTRESOURCE(nID);
  289. pTTT->hinst = AfxGetInstanceHandle();
  290. *pResult = 0;
  291. // bring the tooltip window above other popup windows
  292. ::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,
  293. SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER);
  294. return TRUE;    // message was handled
  295. }
  296. INT_PTR CPropertiesDialog::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
  297. {
  298. HWND hWndChild = NULL;
  299. // find child window which hits the point
  300. // (don't use WindowFromPoint, because it ignores disabled windows)
  301. // see _AfxChildWindowFromPoint(m_hWnd, point);
  302. ::ClientToScreen(m_hWnd, &point);
  303. HWND hChild = ::GetWindow(m_hWnd, GW_CHILD);
  304. for (; hChild != NULL; hChild = ::GetWindow(hChild, GW_HWNDNEXT))
  305. {
  306. if ((UINT)(WORD)::GetDlgCtrlID(hChild) != (WORD)-1 &&
  307. (::GetWindowLong(hChild, GWL_STYLE) & WS_VISIBLE))
  308. {
  309.             // see if point hits the child window
  310.             CRect rect;
  311.             ::GetWindowRect(hChild, rect);
  312.             if (rect.PtInRect(point))
  313.             {
  314. hWndChild = hChild;
  315. break;
  316.             }
  317. }
  318. }
  319. if (hWndChild != NULL)
  320. {
  321. // return positive hit if control ID isn't -1
  322. INT_PTR nHit = (UINT)(WORD)::GetDlgCtrlID(hWndChild);
  323. // hits against child windows always center the tip
  324. if (pTI != NULL && pTI->cbSize >= sizeof(XTP_TOOLTIP_TOOLINFO))
  325. {
  326.             // setup the TOOLINFO structure
  327.             pTI->hwnd = m_hWnd;
  328.             pTI->uId = (UINT_PTR)hWndChild;
  329.             pTI->uFlags |= TTF_IDISHWND;
  330.             pTI->lpszText = LPSTR_TEXTCALLBACK;
  331. // set TTF_NOTBUTTON and TTF_CENTERTIP if it isn't a button
  332. if (!(::SendMessage(hWndChild, WM_GETDLGCODE, 0, 0) &
  333. DLGC_BUTTON))
  334. pTI->uFlags |= TTF_NOTBUTTON|TTF_CENTERTIP;
  335. }
  336. return nHit;
  337. }
  338. return -1;  // not found