ToolTipEx.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. #include "stdafx.h"
  2. #include "cp_main.h"
  3. #include "ToolTipEx.h"
  4. #include "BitmapHelper.h"
  5. #include "Options.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. #define DELETE_BITMAP if(m_pBitmap) \
  12. { \
  13. m_pBitmap->DeleteObject(); \
  14. delete m_pBitmap; \
  15. m_pBitmap = NULL; \
  16. }
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CToolTipEx
  19. CToolTipEx::CToolTipEx(): m_dwTextStyle(DT_EXPANDTABS | DT_EXTERNALLEADING |
  20. DT_NOPREFIX | DT_WORDBREAK), m_rectMargin(2, 2, 3, 3),
  21. m_pBitmap(NULL), m_pNotifyWnd(NULL){}
  22. CToolTipEx::~CToolTipEx()
  23. {
  24. DELETE_BITMAP
  25. m_Font.DeleteObject();
  26. }
  27. BEGIN_MESSAGE_MAP(CToolTipEx, CWnd)
  28. //{{AFX_MSG_MAP(CToolTipEx)
  29. ON_WM_PAINT()
  30. ON_WM_SIZE()
  31. ON_WM_NCHITTEST()
  32. ON_WM_ACTIVATE()
  33. ON_WM_TIMER()
  34. ON_WM_NCPAINT()
  35. ON_WM_NCCALCSIZE()
  36. ON_WM_NCLBUTTONDOWN()
  37. ON_WM_NCMOUSEMOVE()
  38. ON_WM_NCLBUTTONUP()
  39. ON_WM_ERASEBKGND()
  40. ON_COMMAND(ID_FIRST_REMEMBERWINDOWPOSITION, &CToolTipEx::OnRememberwindowposition)
  41. ON_COMMAND(ID_FIRST_SIZEWINDOWTOCONTENT, &CToolTipEx::OnSizewindowtocontent)
  42. ON_COMMAND(ID_FIRST_SCALEIMAGESTOFITWINDOW, &CToolTipEx::OnScaleimagestofitwindow)
  43. ON_COMMAND(2, OnOptions)
  44. ON_WM_RBUTTONDOWN()
  45. ON_WM_SETFOCUS()
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CToolTipEx message handlers
  49. BOOL CToolTipEx::Create(CWnd *pParentWnd)
  50. {
  51. // Get the class name and create the window
  52. CString szClassName = AfxRegisterWndClass(CS_CLASSDC | CS_SAVEBITS,
  53. LoadCursor(NULL, IDC_ARROW));
  54. // Create the window - just don't show it yet.
  55. if( !CWnd::CreateEx(WS_EX_TOPMOST, szClassName, _T(""), WS_POPUP,
  56. 0, 0, 0, 0, pParentWnd->GetSafeHwnd(), 0, NULL))
  57. {
  58. return FALSE;
  59. }
  60. m_DittoWindow.DoCreate(this);
  61. m_DittoWindow.SetCaptionColors(g_Opt.m_Theme.CaptionLeft(), g_Opt.m_Theme.CaptionRight());
  62. m_DittoWindow.SetCaptionOn(this, CGetSetOptions::GetCaptionPos(), true);
  63. m_DittoWindow.m_bDrawMinimize = false;
  64. m_DittoWindow.m_bDrawMinimize = false;
  65. m_DittoWindow.m_bDrawChevron = false;
  66. m_DittoWindow.m_sendWMClose = false;
  67. m_RichEdit.Create(_T(""), _T(""), WS_CHILD | WS_VISIBLE | WS_VSCROLL |
  68. WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL |
  69. ES_AUTOHSCROLL, CRect(10, 10, 100, 200), this, 1);
  70. m_RichEdit.SetReadOnly();
  71. m_RichEdit.SetBackgroundColor(FALSE, GetSysColor(COLOR_INFOBK));
  72. SetLogFont(GetSystemToolTipFont(), FALSE);
  73. m_optionsButton.Create(NULL, WS_CHILD | BS_OWNERDRAW | WS_TABSTOP, CRect(0, 0, 0, 0), this, 2);
  74. m_optionsButton.LoadStdImageDPI(IDB_COG_16_16, IDB_COG_20_20, IDB_COG_24_24, IDB_COG_32_32, _T("PNG"));
  75. m_optionsButton.SetToolTipText(theApp.m_Language.GetString(_T("DescriptionOptionsTooltip"), _T("Description Options")));
  76. m_optionsButton.ShowWindow(SW_SHOW);
  77. return TRUE;
  78. }
  79. BOOL CToolTipEx::Show(CPoint point)
  80. {
  81. m_reducedWindowSize = false;
  82. if(m_pBitmap)
  83. {
  84. m_RichEdit.ShowWindow(SW_HIDE);
  85. }
  86. else
  87. {
  88. m_RichEdit.ShowWindow(SW_SHOW);
  89. //m_RichEdit.SetFocus();
  90. }
  91. CRect rect;
  92. if(CGetSetOptions::GetSizeDescWindowToContent() == FALSE)
  93. {
  94. rect.left = point.x;
  95. rect.top = point.y;
  96. CSize size;
  97. CGetSetOptions::GetDescWndSize(size);
  98. rect.right = rect.left + size.cx;
  99. rect.bottom = rect.top + size.cy;
  100. EnsureWindowVisible(&rect);
  101. }
  102. else
  103. {
  104. rect = GetBoundsRect();
  105. //account for the scroll bars
  106. rect.right += 20;
  107. rect.bottom += 20;
  108. if (m_pBitmap)
  109. {
  110. int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
  111. int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
  112. rect.right = rect.left + nWidth;
  113. rect.bottom = rect.top + nHeight;
  114. }
  115. else if(m_csRTF != "")
  116. {
  117. //if showing rtf then increase the size because
  118. //rtf will probably draw bigger
  119. long lNewWidth = (long)rect.Width() + (long)(rect.Width() *.3);
  120. rect.right = rect.left + lNewWidth;
  121. long lNewHeight = rect.Height() + (rect.Height() *1);
  122. rect.bottom = rect.top + lNewHeight;
  123. }
  124. rect.right += CAPTION_BORDER * 2;
  125. rect.bottom += CAPTION_BORDER * 2;
  126. CRect rcScreen;
  127. ClientToScreen(rect);
  128. CRect cr(point, point);
  129. int nMonitor = GetMonitorFromRect(&cr);
  130. GetMonitorRect(nMonitor, &rcScreen);
  131. //ensure that we don't go outside the screen
  132. if(point.x < 0)
  133. {
  134. point.x = 5;
  135. m_reducedWindowSize = true;
  136. }
  137. if(point.y < 0)
  138. {
  139. point.y = 5;
  140. m_reducedWindowSize = true;
  141. }
  142. rcScreen.DeflateRect(0, 0, 5, 5);
  143. long lWidth = rect.Width();
  144. long lHeight = rect.Height();
  145. rect.left = point.x;
  146. rect.top = point.y;
  147. rect.right = rect.left + lWidth;
  148. rect.bottom = rect.top + lHeight;
  149. if (rect.right > rcScreen.right)
  150. {
  151. int diff = rect.right - rcScreen.right;
  152. int newLeft = rect.left - diff;
  153. if (newLeft > rcScreen.left)
  154. {
  155. rect.left = newLeft;
  156. }
  157. else
  158. {
  159. rect.left = rcScreen.left;
  160. }
  161. rect.right = rcScreen.right;
  162. m_reducedWindowSize = true;
  163. }
  164. if (rect.bottom > rcScreen.bottom)
  165. {
  166. int diff = rect.bottom - rcScreen.bottom;
  167. int newTop = rect.top - diff;
  168. if (newTop > 0)
  169. {
  170. rect.top = newTop;
  171. }
  172. rect.bottom = rcScreen.bottom;
  173. m_reducedWindowSize = true;
  174. }
  175. }
  176. SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height
  177. (), SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOACTIVATE |
  178. SWP_NOZORDER);
  179. return TRUE;
  180. }
  181. BOOL CToolTipEx::Hide()
  182. {
  183. DELETE_BITMAP
  184. ShowWindow(SW_HIDE);
  185. m_csRTF = "";
  186. m_csText = "";
  187. CRect rect;
  188. this->GetWindowRect(&rect);
  189. CGetSetOptions::SetDescWndSize(rect.Size());
  190. CGetSetOptions::SetDescWndPoint(rect.TopLeft());
  191. return TRUE;
  192. }
  193. void CToolTipEx::OnPaint()
  194. {
  195. CPaintDC dc(this); // device context for painting
  196. CRect rect;
  197. GetClientRect(rect);
  198. // Draw Text
  199. // dc.SetBkMode(TRANSPARENT);
  200. // rect.DeflateRect(m_rectMargin);
  201. CBrush Brush, *pOldBrush;
  202. Brush.CreateSolidBrush(GetSysColor(COLOR_INFOBK));
  203. pOldBrush = dc.SelectObject(&Brush);
  204. CFont *pOldFont = dc.SelectObject(&m_Font);
  205. dc.FillRect(&rect, &Brush);
  206. if(m_pBitmap)
  207. {
  208. CDC MemDc;
  209. MemDc.CreateCompatibleDC(&dc);
  210. CBitmap *oldBitmap = MemDc.SelectObject(m_pBitmap);
  211. int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
  212. int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
  213. if(CGetSetOptions::GetScaleImagesToDescWindow())
  214. {
  215. dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nHeight, SRCCOPY);
  216. //OutputDebugString(StrF(_T("scaling image, window size %d/%d, image %d/%d\n"), min(nWidth, rect.Width()), min(nHeight, rect.Height()), nWidth, nHeight));
  217. }
  218. else
  219. {
  220. dc.BitBlt(rect.left, rect.top, nWidth, nHeight, &MemDc, 0, 0, SRCCOPY);
  221. }
  222. //dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nHeight, SRCCOPY);
  223. MemDc.SelectObject(oldBitmap);
  224. rect.top += nHeight;
  225. }
  226. //dc.DrawText(m_csText, rect, m_dwTextStyle);
  227. // Cleanup
  228. // dc.SelectObject(pOldBrush);
  229. // dc.SelectObject(pOldFont);
  230. }
  231. void CToolTipEx::PostNcDestroy()
  232. {
  233. CWnd::PostNcDestroy();
  234. delete this;
  235. }
  236. BOOL CToolTipEx::PreTranslateMessage(MSG *pMsg)
  237. {
  238. m_DittoWindow.DoPreTranslateMessage(pMsg);
  239. switch(pMsg->message)
  240. {
  241. case WM_KEYDOWN:
  242. switch(pMsg->wParam)
  243. {
  244. case VK_ESCAPE:
  245. Hide();
  246. return TRUE;
  247. case 'C':
  248. if(GetKeyState(VK_CONTROL) &0x8000)
  249. {
  250. m_RichEdit.Copy();
  251. }
  252. break;
  253. }
  254. break;
  255. case WM_RBUTTONDOWN:
  256. {
  257. if (m_RichEdit.m_hWnd == GetFocus()->m_hWnd)
  258. {
  259. OnOptions();
  260. return TRUE;
  261. }
  262. }
  263. break;
  264. }
  265. return CWnd::PreTranslateMessage(pMsg);
  266. }
  267. BOOL CToolTipEx::OnMsg(MSG *pMsg)
  268. {
  269. if(FALSE == IsWindowVisible())
  270. {
  271. return FALSE;
  272. }
  273. switch(pMsg->message)
  274. {
  275. case WM_WINDOWPOSCHANGING:
  276. case WM_LBUTTONDOWN:
  277. {
  278. if(!IsCursorInToolTip())
  279. {
  280. Hide();
  281. }
  282. break;
  283. }
  284. case WM_KEYDOWN:
  285. {
  286. WPARAM vk = pMsg->wParam;
  287. if(vk == VK_ESCAPE)
  288. {
  289. Hide();
  290. return TRUE;
  291. }
  292. else if(vk == VK_TAB)
  293. {
  294. m_RichEdit.SetFocus();
  295. return TRUE;
  296. }
  297. else if(vk == 'N')
  298. {
  299. return FALSE;
  300. }
  301. else if (vk == 'P')
  302. {
  303. return FALSE;
  304. }
  305. Hide();
  306. break;
  307. }
  308. case WM_LBUTTONDBLCLK:
  309. case WM_RBUTTONDBLCLK:
  310. case WM_MBUTTONDOWN:
  311. case WM_MBUTTONDBLCLK:
  312. case WM_NCLBUTTONDOWN:
  313. case WM_NCLBUTTONDBLCLK:
  314. case WM_NCRBUTTONDOWN:
  315. case WM_NCRBUTTONDBLCLK:
  316. case WM_NCMBUTTONDOWN:
  317. case WM_NCMBUTTONDBLCLK:
  318. {
  319. Hide();
  320. break;
  321. }
  322. }
  323. return FALSE;
  324. }
  325. CRect CToolTipEx::GetBoundsRect()
  326. {
  327. CWindowDC dc(NULL);
  328. CFont *pOldFont = (CFont*)dc.SelectObject((CFont*) &m_Font);
  329. int nLineWidth = 0;
  330. if(nLineWidth == 0)
  331. {
  332. // Count the number of lines of text
  333. int nStart = 0, nNumLines = 0;
  334. CString strTextCopy = m_csText;
  335. do
  336. {
  337. nStart = strTextCopy.Find(_T("\n"));
  338. // skip found character
  339. if(nStart >= 0)
  340. {
  341. strTextCopy = strTextCopy.Mid(nStart + 1);
  342. }
  343. nNumLines++;
  344. }
  345. while(nStart >= 0);
  346. // Find the widest line
  347. for(int i = 0; i < nNumLines; i++)
  348. {
  349. CString strLine = GetFieldFromString(m_csText, i, _T('\n')) + _T(
  350. " ");
  351. nLineWidth = max(nLineWidth, dc.GetTextExtent(strLine).cx);
  352. }
  353. }
  354. CRect rect(0, 0, max(0, nLineWidth), 0);
  355. dc.DrawText(m_csText, rect, DT_CALCRECT | m_dwTextStyle);
  356. dc.SelectObject(pOldFont);
  357. rect.bottom += m_rectMargin.top + m_rectMargin.bottom;
  358. rect.right += m_rectMargin.left + m_rectMargin.right + 2;
  359. if(m_pBitmap)
  360. {
  361. int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
  362. int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
  363. rect.bottom += nHeight;
  364. if((rect.left + nWidth) > rect.right)
  365. {
  366. rect.right = rect.left + nWidth;
  367. }
  368. }
  369. return rect;
  370. }
  371. CString CToolTipEx::GetFieldFromString(CString ref, int nIndex, TCHAR ch)
  372. {
  373. CString strReturn;
  374. LPCTSTR pstrStart = ref.LockBuffer();
  375. LPCTSTR pstrBuffer = pstrStart;
  376. int nCurrent = 0;
  377. int nStart = 0;
  378. int nEnd = 0;
  379. int nOldStart = 0;
  380. while(nCurrent <= nIndex && *pstrBuffer != _T('\0'))
  381. {
  382. if(*pstrBuffer == ch)
  383. {
  384. nOldStart = nStart;
  385. nStart = nEnd + 1;
  386. nCurrent++;
  387. }
  388. nEnd++;
  389. pstrBuffer++;
  390. }
  391. // May have reached the end of the string
  392. if(*pstrBuffer == _T('\0'))
  393. {
  394. nOldStart = nStart;
  395. nEnd++;
  396. }
  397. ref.UnlockBuffer();
  398. if(nCurrent < nIndex)
  399. {
  400. //TRACE1("Warning: GetStringField - Couldn't find field %d.\n", nIndex);
  401. return strReturn;
  402. }
  403. return ref.Mid(nOldStart, nEnd - nOldStart - 1);
  404. }
  405. LPLOGFONT CToolTipEx::GetSystemToolTipFont()
  406. {
  407. static LOGFONT LogFont;
  408. NONCLIENTMETRICS ncm;
  409. ncm.cbSize = sizeof(NONCLIENTMETRICS);
  410. if(!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
  411. &ncm, 0))
  412. {
  413. return FALSE;
  414. }
  415. memcpy(&LogFont, &(ncm.lfStatusFont), sizeof(LOGFONT));
  416. return &LogFont;
  417. }
  418. BOOL CToolTipEx::SetLogFont(LPLOGFONT lpLogFont, BOOL bRedraw /*=TRUE*/)
  419. {
  420. ASSERT(lpLogFont);
  421. if(!lpLogFont)
  422. {
  423. return FALSE;
  424. }
  425. LOGFONT LogFont;
  426. // Store font as the global default
  427. memcpy(&LogFont, lpLogFont, sizeof(LOGFONT));
  428. // Create the actual font object
  429. m_Font.DeleteObject();
  430. m_Font.CreateFontIndirect(&LogFont);
  431. if(bRedraw && ::IsWindow(GetSafeHwnd()))
  432. {
  433. Invalidate();
  434. }
  435. return TRUE;
  436. }
  437. void CToolTipEx::SetBitmap(CBitmap *pBitmap)
  438. {
  439. DELETE_BITMAP
  440. m_pBitmap = pBitmap;
  441. int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
  442. int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
  443. }
  444. void CToolTipEx::OnSize(UINT nType, int cx, int cy)
  445. {
  446. CWnd::OnSize(nType, cx, cy);
  447. if(::IsWindow(m_RichEdit.GetSafeHwnd()) == FALSE)
  448. {
  449. return ;
  450. }
  451. CRect cr;
  452. GetClientRect(cr);
  453. cr.DeflateRect(0, 0, 0, theApp.m_metrics.ScaleY(21));
  454. m_RichEdit.MoveWindow(cr);
  455. m_optionsButton.MoveWindow(cr.left, cr.bottom + theApp.m_metrics.ScaleY(2), theApp.m_metrics.ScaleX(17), theApp.m_metrics.ScaleY(17));
  456. this->Invalidate();
  457. m_DittoWindow.DoSetRegion(this);
  458. }
  459. BOOL CToolTipEx::IsCursorInToolTip()
  460. {
  461. CRect cr;
  462. GetWindowRect(cr);
  463. CPoint cursorPos;
  464. GetCursorPos(&cursorPos);
  465. return cr.PtInRect(cursorPos);
  466. }
  467. void CToolTipEx::SetRTFText(const char *pRTF)
  468. {
  469. m_RichEdit.SetRTF(pRTF);
  470. m_csRTF = pRTF;
  471. }
  472. //void CToolTipEx::SetRTFText(const CString &csRTF)
  473. //{
  474. // m_RichEdit.SetRTF(csRTF);
  475. // m_csRTF = csRTF;
  476. //}
  477. void CToolTipEx::SetToolTipText(const CString &csText)
  478. {
  479. m_csText = csText;
  480. m_RichEdit.SetFont(&m_Font);
  481. m_RichEdit.SetText(csText);
  482. }
  483. void CToolTipEx::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
  484. {
  485. CWnd::OnActivate(nState, pWndOther, bMinimized);
  486. if(nState == WA_INACTIVE)
  487. {
  488. Hide();
  489. if(m_pNotifyWnd)
  490. {
  491. m_pNotifyWnd->PostMessage(NM_INACTIVE_TOOLTIPWND, 0, 0);
  492. }
  493. }
  494. }
  495. void CToolTipEx::OnTimer(UINT_PTR nIDEvent)
  496. {
  497. switch(nIDEvent)
  498. {
  499. case HIDE_WINDOW_TIMER:
  500. Hide();
  501. PostMessage(WM_DESTROY, 0, 0);
  502. break;
  503. }
  504. CWnd::OnTimer(nIDEvent);
  505. }
  506. void CToolTipEx::OnNcPaint()
  507. {
  508. m_DittoWindow.DoNcPaint(this);
  509. }
  510. void CToolTipEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
  511. {
  512. CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
  513. m_DittoWindow.DoNcCalcSize(bCalcValidRects, lpncsp);
  514. }
  515. HITTEST_RET CToolTipEx::OnNcHitTest(CPoint point)
  516. {
  517. UINT Ret = m_DittoWindow.DoNcHitTest(this, point);
  518. if(Ret == -1)
  519. return CWnd::OnNcHitTest(point);
  520. return Ret;
  521. }
  522. void CToolTipEx::OnNcLButtonDown(UINT nHitTest, CPoint point)
  523. {
  524. m_DittoWindow.DoNcLButtonDown(this, nHitTest, point);
  525. CWnd::OnNcLButtonDown(nHitTest, point);
  526. }
  527. void CToolTipEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
  528. {
  529. long lRet = m_DittoWindow.DoNcLButtonUp(this, nHitTest, point);
  530. switch(lRet)
  531. {
  532. case BUTTON_CLOSE:
  533. Hide();
  534. break;
  535. }
  536. CWnd::OnNcLButtonUp(nHitTest, point);
  537. }
  538. void CToolTipEx::OnNcMouseMove(UINT nHitTest, CPoint point)
  539. {
  540. m_DittoWindow.DoNcMouseMove(this, nHitTest, point);
  541. CWnd::OnNcMouseMove(nHitTest, point);
  542. }
  543. void CToolTipEx::OnOptions()
  544. {
  545. POINT pp;
  546. CMenu cmPopUp;
  547. CMenu *cmSubMenu = NULL;
  548. GetCursorPos(&pp);
  549. if(cmPopUp.LoadMenu(IDR_DESC_OPTIONS_MENU) != 0)
  550. {
  551. cmSubMenu = cmPopUp.GetSubMenu(0);
  552. if(!cmSubMenu)
  553. {
  554. return ;
  555. }
  556. GetCursorPos(&pp);
  557. if(CGetSetOptions::GetRememberDescPos())
  558. cmSubMenu->CheckMenuItem(ID_FIRST_REMEMBERWINDOWPOSITION, MF_CHECKED);
  559. if(CGetSetOptions::GetSizeDescWindowToContent())
  560. cmSubMenu->CheckMenuItem(ID_FIRST_SIZEWINDOWTOCONTENT, MF_CHECKED);
  561. if(CGetSetOptions::GetScaleImagesToDescWindow())
  562. cmSubMenu->CheckMenuItem(ID_FIRST_SCALEIMAGESTOFITWINDOW, MF_CHECKED);
  563. //theApp.m_Language.UpdateRightClickMenu(cmSubMenu);
  564. cmSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, pp.x, pp.y, this, NULL);
  565. }
  566. }
  567. void CToolTipEx::OnRememberwindowposition()
  568. {
  569. CGetSetOptions::SetRememberDescPos(!CGetSetOptions::GetRememberDescPos());
  570. }
  571. void CToolTipEx::OnSizewindowtocontent()
  572. {
  573. CGetSetOptions::SetSizeDescWindowToContent(!CGetSetOptions::GetSizeDescWindowToContent());
  574. CRect rect;
  575. this->GetWindowRect(&rect);
  576. Show(rect.TopLeft());
  577. }
  578. void CToolTipEx::OnScaleimagestofitwindow()
  579. {
  580. CGetSetOptions::SetScaleImagesToDescWindow(!CGetSetOptions::GetScaleImagesToDescWindow());
  581. Invalidate();
  582. }
  583. void CToolTipEx::OnRButtonDown(UINT nFlags, CPoint point)
  584. {
  585. OnOptions();
  586. CWnd::OnRButtonDown(nFlags, point);
  587. }
  588. void CToolTipEx::OnSetFocus(CWnd* pOldWnd)
  589. {
  590. CWnd::OnSetFocus(pOldWnd);
  591. m_RichEdit.SetFocus();
  592. }