ToolTipEx.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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, CAPTION_LEFT, 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 > 0)
  154. {
  155. rect.left = newLeft;
  156. }
  157. rect.right = rcScreen.right;
  158. m_reducedWindowSize = true;
  159. }
  160. if(rect.bottom > rcScreen.bottom)
  161. {
  162. int diff = rect.bottom - rcScreen.bottom;
  163. int newTop = rect.top - diff;
  164. if(newTop > 0)
  165. {
  166. rect.top = newTop;
  167. }
  168. rect.bottom = rcScreen.bottom;
  169. m_reducedWindowSize = true;
  170. }
  171. }
  172. SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height
  173. (), SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOACTIVATE |
  174. SWP_NOZORDER);
  175. return TRUE;
  176. }
  177. BOOL CToolTipEx::Hide()
  178. {
  179. DELETE_BITMAP
  180. ShowWindow(SW_HIDE);
  181. m_csRTF = "";
  182. m_csText = "";
  183. CRect rect;
  184. this->GetWindowRect(&rect);
  185. CGetSetOptions::SetDescWndSize(rect.Size());
  186. CGetSetOptions::SetDescWndPoint(rect.TopLeft());
  187. return TRUE;
  188. }
  189. void CToolTipEx::OnPaint()
  190. {
  191. CPaintDC dc(this); // device context for painting
  192. CRect rect;
  193. GetClientRect(rect);
  194. // Draw Text
  195. // dc.SetBkMode(TRANSPARENT);
  196. // rect.DeflateRect(m_rectMargin);
  197. CBrush Brush, *pOldBrush;
  198. Brush.CreateSolidBrush(GetSysColor(COLOR_INFOBK));
  199. pOldBrush = dc.SelectObject(&Brush);
  200. CFont *pOldFont = dc.SelectObject(&m_Font);
  201. dc.FillRect(&rect, &Brush);
  202. if(m_pBitmap)
  203. {
  204. CDC MemDc;
  205. MemDc.CreateCompatibleDC(&dc);
  206. CBitmap *oldBitmap = MemDc.SelectObject(m_pBitmap);
  207. int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
  208. int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
  209. if(CGetSetOptions::GetScaleImagesToDescWindow())
  210. {
  211. dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nWidth, SRCCOPY);
  212. }
  213. else
  214. {
  215. dc.BitBlt(rect.left, rect.top, nWidth, nHeight, &MemDc, 0, 0, SRCCOPY);
  216. }
  217. //dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(), &MemDc, 0, 0, nWidth, nHeight, SRCCOPY);
  218. MemDc.SelectObject(oldBitmap);
  219. rect.top += nHeight;
  220. }
  221. //dc.DrawText(m_csText, rect, m_dwTextStyle);
  222. // Cleanup
  223. // dc.SelectObject(pOldBrush);
  224. // dc.SelectObject(pOldFont);
  225. }
  226. void CToolTipEx::PostNcDestroy()
  227. {
  228. CWnd::PostNcDestroy();
  229. delete this;
  230. }
  231. BOOL CToolTipEx::PreTranslateMessage(MSG *pMsg)
  232. {
  233. m_DittoWindow.DoPreTranslateMessage(pMsg);
  234. switch(pMsg->message)
  235. {
  236. case WM_KEYDOWN:
  237. switch(pMsg->wParam)
  238. {
  239. case VK_ESCAPE:
  240. Hide();
  241. return TRUE;
  242. case 'C':
  243. if(GetKeyState(VK_CONTROL) &0x8000)
  244. {
  245. m_RichEdit.Copy();
  246. }
  247. break;
  248. }
  249. break;
  250. case WM_RBUTTONDOWN:
  251. {
  252. if (m_RichEdit.m_hWnd == GetFocus()->m_hWnd)
  253. {
  254. OnOptions();
  255. return TRUE;
  256. }
  257. }
  258. break;
  259. }
  260. return CWnd::PreTranslateMessage(pMsg);
  261. }
  262. BOOL CToolTipEx::OnMsg(MSG *pMsg)
  263. {
  264. if(FALSE == IsWindowVisible())
  265. {
  266. return FALSE;
  267. }
  268. switch(pMsg->message)
  269. {
  270. case WM_WINDOWPOSCHANGING:
  271. case WM_LBUTTONDOWN:
  272. {
  273. if(!IsCursorInToolTip())
  274. {
  275. Hide();
  276. }
  277. break;
  278. }
  279. case WM_KEYDOWN:
  280. {
  281. WPARAM vk = pMsg->wParam;
  282. if(vk == VK_ESCAPE)
  283. {
  284. Hide();
  285. return TRUE;
  286. }
  287. else if(vk == VK_TAB)
  288. {
  289. m_RichEdit.SetFocus();
  290. return TRUE;
  291. }
  292. else if(vk == 'N')
  293. {
  294. return FALSE;
  295. }
  296. else if (vk == 'P')
  297. {
  298. return FALSE;
  299. }
  300. Hide();
  301. break;
  302. }
  303. case WM_LBUTTONDBLCLK:
  304. case WM_RBUTTONDBLCLK:
  305. case WM_MBUTTONDOWN:
  306. case WM_MBUTTONDBLCLK:
  307. case WM_NCLBUTTONDOWN:
  308. case WM_NCLBUTTONDBLCLK:
  309. case WM_NCRBUTTONDOWN:
  310. case WM_NCRBUTTONDBLCLK:
  311. case WM_NCMBUTTONDOWN:
  312. case WM_NCMBUTTONDBLCLK:
  313. {
  314. Hide();
  315. break;
  316. }
  317. }
  318. return FALSE;
  319. }
  320. CRect CToolTipEx::GetBoundsRect()
  321. {
  322. CWindowDC dc(NULL);
  323. CFont *pOldFont = (CFont*)dc.SelectObject((CFont*) &m_Font);
  324. int nLineWidth = 0;
  325. if(nLineWidth == 0)
  326. {
  327. // Count the number of lines of text
  328. int nStart = 0, nNumLines = 0;
  329. CString strTextCopy = m_csText;
  330. do
  331. {
  332. nStart = strTextCopy.Find(_T("\n"));
  333. // skip found character
  334. if(nStart >= 0)
  335. {
  336. strTextCopy = strTextCopy.Mid(nStart + 1);
  337. }
  338. nNumLines++;
  339. }
  340. while(nStart >= 0);
  341. // Find the widest line
  342. for(int i = 0; i < nNumLines; i++)
  343. {
  344. CString strLine = GetFieldFromString(m_csText, i, _T('\n')) + _T(
  345. " ");
  346. nLineWidth = max(nLineWidth, dc.GetTextExtent(strLine).cx);
  347. }
  348. }
  349. CRect rect(0, 0, max(0, nLineWidth), 0);
  350. dc.DrawText(m_csText, rect, DT_CALCRECT | m_dwTextStyle);
  351. dc.SelectObject(pOldFont);
  352. rect.bottom += m_rectMargin.top + m_rectMargin.bottom;
  353. rect.right += m_rectMargin.left + m_rectMargin.right + 2;
  354. if(m_pBitmap)
  355. {
  356. int nWidth = CBitmapHelper::GetCBitmapWidth(*m_pBitmap);
  357. int nHeight = CBitmapHelper::GetCBitmapHeight(*m_pBitmap);
  358. rect.bottom += nHeight;
  359. if((rect.left + nWidth) > rect.right)
  360. {
  361. rect.right = rect.left + nWidth;
  362. }
  363. }
  364. return rect;
  365. }
  366. CString CToolTipEx::GetFieldFromString(CString ref, int nIndex, TCHAR ch)
  367. {
  368. CString strReturn;
  369. LPCTSTR pstrStart = ref.LockBuffer();
  370. LPCTSTR pstrBuffer = pstrStart;
  371. int nCurrent = 0;
  372. int nStart = 0;
  373. int nEnd = 0;
  374. int nOldStart = 0;
  375. while(nCurrent <= nIndex && *pstrBuffer != _T('\0'))
  376. {
  377. if(*pstrBuffer == ch)
  378. {
  379. nOldStart = nStart;
  380. nStart = nEnd + 1;
  381. nCurrent++;
  382. }
  383. nEnd++;
  384. pstrBuffer++;
  385. }
  386. // May have reached the end of the string
  387. if(*pstrBuffer == _T('\0'))
  388. {
  389. nOldStart = nStart;
  390. nEnd++;
  391. }
  392. ref.UnlockBuffer();
  393. if(nCurrent < nIndex)
  394. {
  395. //TRACE1("Warning: GetStringField - Couldn't find field %d.\n", nIndex);
  396. return strReturn;
  397. }
  398. return ref.Mid(nOldStart, nEnd - nOldStart - 1);
  399. }
  400. LPLOGFONT CToolTipEx::GetSystemToolTipFont()
  401. {
  402. static LOGFONT LogFont;
  403. NONCLIENTMETRICS ncm;
  404. ncm.cbSize = sizeof(NONCLIENTMETRICS);
  405. if(!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
  406. &ncm, 0))
  407. {
  408. return FALSE;
  409. }
  410. memcpy(&LogFont, &(ncm.lfStatusFont), sizeof(LOGFONT));
  411. return &LogFont;
  412. }
  413. BOOL CToolTipEx::SetLogFont(LPLOGFONT lpLogFont, BOOL bRedraw /*=TRUE*/)
  414. {
  415. ASSERT(lpLogFont);
  416. if(!lpLogFont)
  417. {
  418. return FALSE;
  419. }
  420. LOGFONT LogFont;
  421. // Store font as the global default
  422. memcpy(&LogFont, lpLogFont, sizeof(LOGFONT));
  423. // Create the actual font object
  424. m_Font.DeleteObject();
  425. m_Font.CreateFontIndirect(&LogFont);
  426. if(bRedraw && ::IsWindow(GetSafeHwnd()))
  427. {
  428. Invalidate();
  429. }
  430. return TRUE;
  431. }
  432. void CToolTipEx::SetBitmap(CBitmap *pBitmap)
  433. {
  434. DELETE_BITMAP
  435. m_pBitmap = pBitmap;
  436. }
  437. void CToolTipEx::OnSize(UINT nType, int cx, int cy)
  438. {
  439. CWnd::OnSize(nType, cx, cy);
  440. if(::IsWindow(m_RichEdit.GetSafeHwnd()) == FALSE)
  441. {
  442. return ;
  443. }
  444. CRect cr;
  445. GetClientRect(cr);
  446. cr.DeflateRect(0, 0, 0, theApp.m_metrics.ScaleY(21));
  447. m_RichEdit.MoveWindow(cr);
  448. m_optionsButton.MoveWindow(cr.left, cr.bottom + theApp.m_metrics.ScaleY(2), theApp.m_metrics.ScaleX(17), theApp.m_metrics.ScaleY(17));
  449. //this->Invalidate();
  450. m_DittoWindow.DoSetRegion(this);
  451. }
  452. BOOL CToolTipEx::IsCursorInToolTip()
  453. {
  454. CRect cr;
  455. GetWindowRect(cr);
  456. CPoint cursorPos;
  457. GetCursorPos(&cursorPos);
  458. return cr.PtInRect(cursorPos);
  459. }
  460. void CToolTipEx::SetRTFText(const char *pRTF)
  461. {
  462. m_RichEdit.SetRTF(pRTF);
  463. m_csRTF = pRTF;
  464. }
  465. //void CToolTipEx::SetRTFText(const CString &csRTF)
  466. //{
  467. // m_RichEdit.SetRTF(csRTF);
  468. // m_csRTF = csRTF;
  469. //}
  470. void CToolTipEx::SetToolTipText(const CString &csText)
  471. {
  472. m_csText = csText;
  473. m_RichEdit.SetFont(&m_Font);
  474. m_RichEdit.SetText(csText);
  475. }
  476. void CToolTipEx::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
  477. {
  478. CWnd::OnActivate(nState, pWndOther, bMinimized);
  479. if(nState == WA_INACTIVE)
  480. {
  481. Hide();
  482. if(m_pNotifyWnd)
  483. {
  484. m_pNotifyWnd->PostMessage(NM_INACTIVE_TOOLTIPWND, 0, 0);
  485. }
  486. }
  487. }
  488. void CToolTipEx::OnTimer(UINT_PTR nIDEvent)
  489. {
  490. switch(nIDEvent)
  491. {
  492. case HIDE_WINDOW_TIMER:
  493. Hide();
  494. PostMessage(WM_DESTROY, 0, 0);
  495. break;
  496. }
  497. CWnd::OnTimer(nIDEvent);
  498. }
  499. void CToolTipEx::OnNcPaint()
  500. {
  501. m_DittoWindow.DoNcPaint(this);
  502. }
  503. void CToolTipEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
  504. {
  505. CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
  506. m_DittoWindow.DoNcCalcSize(bCalcValidRects, lpncsp);
  507. }
  508. HITTEST_RET CToolTipEx::OnNcHitTest(CPoint point)
  509. {
  510. UINT Ret = m_DittoWindow.DoNcHitTest(this, point);
  511. if(Ret == -1)
  512. return CWnd::OnNcHitTest(point);
  513. return Ret;
  514. }
  515. void CToolTipEx::OnNcLButtonDown(UINT nHitTest, CPoint point)
  516. {
  517. m_DittoWindow.DoNcLButtonDown(this, nHitTest, point);
  518. CWnd::OnNcLButtonDown(nHitTest, point);
  519. }
  520. void CToolTipEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
  521. {
  522. long lRet = m_DittoWindow.DoNcLButtonUp(this, nHitTest, point);
  523. switch(lRet)
  524. {
  525. case BUTTON_CLOSE:
  526. Hide();
  527. break;
  528. }
  529. CWnd::OnNcLButtonUp(nHitTest, point);
  530. }
  531. void CToolTipEx::OnNcMouseMove(UINT nHitTest, CPoint point)
  532. {
  533. m_DittoWindow.DoNcMouseMove(this, nHitTest, point);
  534. CWnd::OnNcMouseMove(nHitTest, point);
  535. }
  536. void CToolTipEx::OnOptions()
  537. {
  538. POINT pp;
  539. CMenu cmPopUp;
  540. CMenu *cmSubMenu = NULL;
  541. GetCursorPos(&pp);
  542. if(cmPopUp.LoadMenu(IDR_DESC_OPTIONS_MENU) != 0)
  543. {
  544. cmSubMenu = cmPopUp.GetSubMenu(0);
  545. if(!cmSubMenu)
  546. {
  547. return ;
  548. }
  549. GetCursorPos(&pp);
  550. if(CGetSetOptions::GetRememberDescPos())
  551. cmSubMenu->CheckMenuItem(ID_FIRST_REMEMBERWINDOWPOSITION, MF_CHECKED);
  552. if(CGetSetOptions::GetSizeDescWindowToContent())
  553. cmSubMenu->CheckMenuItem(ID_FIRST_SIZEWINDOWTOCONTENT, MF_CHECKED);
  554. if(CGetSetOptions::GetScaleImagesToDescWindow())
  555. cmSubMenu->CheckMenuItem(ID_FIRST_SCALEIMAGESTOFITWINDOW, MF_CHECKED);
  556. //theApp.m_Language.UpdateRightClickMenu(cmSubMenu);
  557. cmSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, pp.x, pp.y, this, NULL);
  558. }
  559. }
  560. void CToolTipEx::OnRememberwindowposition()
  561. {
  562. CGetSetOptions::SetRememberDescPos(!CGetSetOptions::GetRememberDescPos());
  563. }
  564. void CToolTipEx::OnSizewindowtocontent()
  565. {
  566. CGetSetOptions::SetSizeDescWindowToContent(!CGetSetOptions::GetSizeDescWindowToContent());
  567. CRect rect;
  568. this->GetWindowRect(&rect);
  569. Show(rect.TopLeft());
  570. }
  571. void CToolTipEx::OnScaleimagestofitwindow()
  572. {
  573. CGetSetOptions::SetScaleImagesToDescWindow(!CGetSetOptions::GetScaleImagesToDescWindow());
  574. Invalidate();
  575. }
  576. void CToolTipEx::OnRButtonDown(UINT nFlags, CPoint point)
  577. {
  578. OnOptions();
  579. CWnd::OnRButtonDown(nFlags, point);
  580. }
  581. void CToolTipEx::OnSetFocus(CWnd* pOldWnd)
  582. {
  583. CWnd::OnSetFocus(pOldWnd);
  584. m_RichEdit.SetFocus();
  585. }