ToolTipEx.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338
  1. #include "stdafx.h"
  2. #include "cp_main.h"
  3. #include "ToolTipEx.h"
  4. #include "BitmapHelper.h"
  5. #include "Options.h"
  6. #include "ActionEnums.h"
  7. #include "HyperLink.h"
  8. #include <Richedit.h>
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. #define HIDE_WINDOW_TIMER 1
  15. #define SAVE_SIZE 2
  16. #define TIMER_BUTTON_UP 3
  17. #define TIMER_AUTO_MAX 4
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CToolTipEx
  20. CToolTipEx::CToolTipEx(): m_dwTextStyle(DT_EXPANDTABS | DT_EXTERNALLEADING |
  21. DT_NOPREFIX | DT_WORDBREAK), m_rectMargin(2, 2, 3, 3),
  22. m_pNotifyWnd(NULL), m_clipId(0), m_clipRow(-1)
  23. {
  24. m_showPersistant = false;
  25. m_pToolTipActions = NULL;
  26. m_bMaxSetTimer = false;
  27. m_lDelayMaxSeconds = 2;
  28. }
  29. CToolTipEx::~CToolTipEx()
  30. {
  31. m_Font.DeleteObject();
  32. m_clipDataFont.DeleteObject();
  33. }
  34. BEGIN_MESSAGE_MAP(CToolTipEx, CWnd)
  35. //{{AFX_MSG_MAP(CToolTipEx)
  36. ON_WM_PAINT()
  37. ON_WM_SIZE()
  38. ON_WM_NCHITTEST()
  39. ON_WM_ACTIVATE()
  40. ON_WM_TIMER()
  41. ON_WM_NCLBUTTONDBLCLK()
  42. ON_WM_NCPAINT()
  43. ON_WM_NCCALCSIZE()
  44. ON_WM_NCLBUTTONDOWN()
  45. ON_WM_NCMOUSEMOVE()
  46. ON_WM_NCLBUTTONUP()
  47. ON_WM_ERASEBKGND()
  48. ON_COMMAND(ID_FIRST_REMEMBERWINDOWPOSITION, &CToolTipEx::OnRememberwindowposition)
  49. ON_COMMAND(ID_FIRST_SIZEWINDOWTOCONTENT, &CToolTipEx::OnSizewindowtocontent)
  50. ON_COMMAND(ID_FIRST_SCALEIMAGESTOFITWINDOW, &CToolTipEx::OnScaleimagestofitwindow)
  51. ON_COMMAND(2, OnOptions)
  52. ON_WM_RBUTTONDOWN()
  53. ON_WM_SETFOCUS()
  54. ON_COMMAND(ID_FIRST_HIDEDESCRIPTIONWINDOWONM, &CToolTipEx::OnFirstHidedescriptionwindowonm)
  55. ON_COMMAND(ID_FIRST_WRAPTEXT, &CToolTipEx::OnFirstWraptext)
  56. ON_WM_WINDOWPOSCHANGING()
  57. ON_COMMAND(ID_FIRST_ALWAYSONTOP, &CToolTipEx::OnFirstAlwaysontop)
  58. ON_NOTIFY(EN_MSGFILTER, 1, &CToolTipEx::OnEnMsgfilterRichedit21)
  59. ON_MESSAGE(WM_DPICHANGED, OnDpiChanged)
  60. ON_WM_MOVING()
  61. ON_WM_ENTERSIZEMOVE()
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CToolTipEx message handlers
  65. BOOL CToolTipEx::Create(CWnd *pParentWnd)
  66. {
  67. m_saveWindowLockout = true;
  68. // Get the class name and create the window
  69. CString szClassName = AfxRegisterWndClass(CS_CLASSDC | CS_SAVEBITS, LoadCursor(NULL, IDC_ARROW));
  70. // Create the window - just don't show it yet.
  71. if( !CWnd::CreateEx(0, szClassName, _T(""), WS_POPUP,
  72. 0, 0, 0, 0, pParentWnd->GetSafeHwnd(), 0, NULL))
  73. {
  74. return FALSE;
  75. }
  76. HICON b = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 64, 64, LR_SHARED);
  77. SetIcon(b, TRUE);
  78. //CString szClassName2 = AfxRegisterWndClass(CS_CLASSDC | CS_SAVEBITS, LoadCursor(NULL, IDC_ARROW));
  79. //BOOL b = m_imageViewer.Create(_T(""), szClassName2, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL, CRect(0, 0, 0, 0), this, 3);
  80. m_imageViewer.Create(this);
  81. m_DittoWindow.DoCreate(this);
  82. m_DittoWindow.SetCaptionColors(g_Opt.m_Theme.CaptionLeft(), g_Opt.m_Theme.CaptionRight(), g_Opt.m_Theme.Border());
  83. m_DittoWindow.SetCaptionOn(this, CGetSetOptions::GetCaptionPos(), true, g_Opt.m_Theme.GetCaptionSize(), g_Opt.m_Theme.GetCaptionFontSize());
  84. m_DittoWindow.m_bDrawMaximize = false;
  85. m_DittoWindow.m_bDrawMinimize = false;
  86. m_DittoWindow.m_bDrawChevron = true;
  87. m_DittoWindow.m_sendWMClose = false;
  88. m_RichEdit.Create(_T(""), _T(""), WS_CHILD | WS_VISIBLE | WS_VSCROLL |
  89. WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_NOHIDESEL |
  90. ES_AUTOHSCROLL, CRect(10, 10, 100, 200), this, 1);
  91. m_RichEdit.SetReadOnly();
  92. m_RichEdit.SetBackgroundColor(FALSE, g_Opt.m_Theme.DescriptionWindowBG());
  93. m_RichEdit.SetEventMask(m_RichEdit.GetEventMask() | ENM_SELCHANGE | ENM_LINK | ENM_MOUSEEVENTS | ENM_SCROLLEVENTS);
  94. m_RichEdit.SetAutoURLDetect(TRUE);
  95. ApplyWordWrap();
  96. m_optionsButton.Create(NULL, WS_CHILD | BS_OWNERDRAW | WS_TABSTOP, CRect(0, 0, 0, 0), this, 2);
  97. m_optionsButton.LoadStdImageDPI(m_DittoWindow.m_dpi.GetDPI(), IDB_COG_16_16, IDB_COG_20_20, IDB_COG_24_24, cog_28, IDB_COG_32_32, _T("PNG"));
  98. m_optionsButton.SetToolTipText(theApp.m_Language.GetString(_T("DescriptionOptionsTooltip"), _T("Description Options")));
  99. m_optionsButton.ShowWindow(SW_SHOW);
  100. m_clipDataStatic.Create(_T("some text"), WS_CHILD | WS_VISIBLE | SS_SIMPLE, CRect(0, 0, 0, 0), this, 3);
  101. m_folderPathStatic.Create(_T("some text"), WS_CHILD | WS_VISIBLE | SS_SIMPLE, CRect(0, 0, 0, 0), this, 4);
  102. m_clipDataFont.CreateFont(-m_DittoWindow.m_dpi.Scale(11), 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 3, 2, 1, 34, _T("Segoe UI"));
  103. m_clipDataStatic.SetFont(&m_clipDataFont);
  104. m_clipDataStatic.SetBkColor(g_Opt.m_Theme.DescriptionWindowBG());
  105. m_clipDataStatic.SetTextColor(RGB(80, 80, 80));
  106. m_folderPathStatic.SetFont(&m_clipDataFont);
  107. m_folderPathStatic.SetBkColor(g_Opt.m_Theme.DescriptionWindowBG());
  108. m_folderPathStatic.SetTextColor(RGB(80, 80, 80));
  109. m_saveWindowLockout = false;
  110. return TRUE;
  111. }
  112. BOOL CToolTipEx::Show(CPoint point)
  113. {
  114. m_reducedWindowSize = false;
  115. if(m_imageViewer.m_pGdiplusBitmap)
  116. {
  117. m_imageViewer.ShowWindow(SW_SHOW);
  118. m_RichEdit.ShowWindow(SW_HIDE);
  119. if (::IsWindow(m_browser.m_hWnd))
  120. {
  121. m_browser.ShowWindow(SW_HIDE);
  122. }
  123. m_imageViewer.UpdateBitmapSize();
  124. }
  125. else if (m_html.GetLength() > 0)
  126. {
  127. if (::IsWindow(m_browser.m_hWnd))
  128. {
  129. m_browser.ShowWindow(SW_SHOW);
  130. }
  131. m_imageViewer.ShowWindow(SW_HIDE);
  132. m_RichEdit.ShowWindow(SW_HIDE);
  133. }
  134. else
  135. {
  136. m_RichEdit.ShowWindow(SW_SHOW);
  137. m_imageViewer.ShowWindow(SW_HIDE);
  138. if (::IsWindow(m_browser.m_hWnd))
  139. {
  140. m_browser.ShowWindow(SW_HIDE);
  141. }
  142. }
  143. CRect rect;
  144. if(CGetSetOptions::GetSizeDescWindowToContent() == FALSE)
  145. {
  146. rect.left = point.x;
  147. rect.top = point.y;
  148. CSize size;
  149. CGetSetOptions::GetDescWndSize(size);
  150. rect.right = rect.left + m_DittoWindow.m_dpi.Scale(size.cx);
  151. rect.bottom = rect.top + m_DittoWindow.m_dpi.Scale(size.cy);
  152. EnsureWindowVisible(&rect);
  153. }
  154. else
  155. {
  156. rect = GetBoundsRect();
  157. //account for the scroll bars
  158. rect.right += 20;
  159. rect.bottom += 20;
  160. if (m_imageViewer.m_pGdiplusBitmap)
  161. {
  162. int nWidth = m_imageViewer.m_pGdiplusBitmap->GetWidth() + ::GetSystemMetrics(SM_CXVSCROLL);
  163. int nHeight = m_imageViewer.m_pGdiplusBitmap->GetHeight() + ::GetSystemMetrics(SM_CYHSCROLL);
  164. rect.right = rect.left + nWidth;
  165. rect.bottom = rect.top + nHeight;
  166. }
  167. else if(m_csRTF != "")
  168. {
  169. //if showing rtf then increase the size because
  170. //rtf will probably draw bigger
  171. long lNewWidth = (long)rect.Width() + (long)(rect.Width() *1.5);
  172. rect.right = rect.left + lNewWidth;
  173. long lNewHeight = (long)rect.Height() + (long)(rect.Height() *1.5);
  174. rect.bottom = rect.top + lNewHeight;
  175. }
  176. //rect.right += CAPTION_BORDER * 2;
  177. //rect.bottom += CAPTION_BORDER * 2;
  178. CRect rcScreen;
  179. ClientToScreen(rect);
  180. CRect cr(point, point);
  181. int nMonitor = GetMonitorFromRect(&cr);
  182. GetMonitorRect(nMonitor, &rcScreen);
  183. //ensure that we don't go outside the screen
  184. if(point.x < 0)
  185. {
  186. point.x = 5;
  187. m_reducedWindowSize = true;
  188. }
  189. if(point.y < 0)
  190. {
  191. point.y = 5;
  192. m_reducedWindowSize = true;
  193. }
  194. rcScreen.DeflateRect(0, 0, 5, 5);
  195. long lWidth = rect.Width();
  196. long lHeight = rect.Height();
  197. rect.left = point.x;
  198. rect.top = point.y;
  199. rect.right = rect.left + lWidth;
  200. rect.bottom = rect.top + lHeight;
  201. if (rect.right > rcScreen.right)
  202. {
  203. rect.right = rcScreen.right;
  204. m_reducedWindowSize = true;
  205. }
  206. if (rect.bottom > rcScreen.bottom)
  207. {
  208. rect.bottom = rcScreen.bottom;
  209. m_reducedWindowSize = true;
  210. }
  211. }
  212. m_clipDataStatic.SetWindowText(m_clipData);
  213. m_folderPathStatic.SetWindowText(m_folderPath);
  214. if (m_DittoWindow.m_bMinimized)
  215. {
  216. //m_DittoWindow.MinMaxWindow(this, FORCE_MAX);
  217. m_DittoWindow.m_bMinimized = false;
  218. }
  219. m_saveWindowLockout = true;
  220. MoveWindow(rect);
  221. ShowWindow(SW_SHOWNA);
  222. this->Invalidate();
  223. this->UpdateWindow();
  224. m_saveWindowLockout = false;
  225. return TRUE;
  226. }
  227. void CToolTipEx::GetWindowRectEx(LPRECT lpRect)
  228. {
  229. if (m_DittoWindow.m_bMinimized)
  230. {
  231. *lpRect = m_DittoWindow.m_crFullSizeWindow;
  232. return;
  233. }
  234. CWnd::GetWindowRect(lpRect);
  235. }
  236. BOOL CToolTipEx::Hide()
  237. {
  238. delete m_imageViewer.m_pGdiplusBitmap;
  239. m_imageViewer.m_pGdiplusBitmap = NULL;
  240. SaveWindowSize();
  241. ShowWindow(SW_HIDE);
  242. m_csRTF = "";
  243. m_csText = "";
  244. m_html = "";
  245. m_clipId = 0;
  246. m_clipRow = -1;
  247. m_searchText = _T("");
  248. m_showPersistant = false;
  249. return TRUE;
  250. }
  251. void CToolTipEx::OnNcLButtonDblClk(UINT nHitTest, CPoint point)
  252. {
  253. // toggle ShowPersistent when we double click the caption
  254. if (nHitTest == HTCAPTION)
  255. {
  256. OnFirstAlwaysontop();
  257. }
  258. CWnd::OnNcLButtonDblClk(nHitTest, point);
  259. }
  260. void CToolTipEx::SaveWindowSize()
  261. {
  262. if (::IsWindowVisible(m_hWnd))
  263. {
  264. CRect rect;
  265. if (m_DittoWindow.m_bMinimized)
  266. {
  267. rect = m_DittoWindow.m_crFullSizeWindow;
  268. }
  269. else
  270. {
  271. this->GetWindowRect(&rect);
  272. }
  273. CSize s = rect.Size();
  274. CGetSetOptions::SetDescWndSize(CSize(m_DittoWindow.m_dpi.UnScale(s.cx), m_DittoWindow.m_dpi.UnScale(s.cy)));
  275. CGetSetOptions::SetDescWndPoint(rect.TopLeft());
  276. OutputDebugString(_T("Saving tooltip size"));
  277. }
  278. }
  279. void CToolTipEx::PostNcDestroy()
  280. {
  281. CWnd::PostNcDestroy();
  282. delete this;
  283. }
  284. BOOL CToolTipEx::PreTranslateMessage(MSG *pMsg)
  285. {
  286. m_DittoWindow.DoPreTranslateMessage(pMsg);
  287. switch (pMsg->message)
  288. {
  289. case WM_KEYDOWN:
  290. switch(pMsg->wParam)
  291. {
  292. case 'C':
  293. if(GetKeyState(VK_CONTROL) &0x8000)
  294. {
  295. m_RichEdit.Copy();
  296. }
  297. break;
  298. }
  299. break;
  300. case WM_RBUTTONDOWN:
  301. {
  302. if (m_RichEdit.m_hWnd == GetFocus()->m_hWnd ||
  303. m_imageViewer.m_hWnd == GetFocus()->m_hWnd)
  304. {
  305. OnOptions();
  306. return TRUE;
  307. }
  308. }
  309. break;
  310. }
  311. if (m_pToolTipActions != NULL)
  312. {
  313. CAccel a;
  314. if (m_pToolTipActions->OnMsg(pMsg, a))
  315. {
  316. switch (a.Cmd)
  317. {
  318. case ActionEnums::CLOSEWINDOW:
  319. /*if (this->m_showPersistant &&
  320. m_DittoWindow.m_bMinimized == false)
  321. {
  322. m_DittoWindow.MinMaxWindow(this, FORCE_MIN);
  323. theApp.m_activeWnd.ReleaseFocus();
  324. return TRUE;
  325. }*/
  326. break;
  327. }
  328. }
  329. }
  330. return CWnd::PreTranslateMessage(pMsg);
  331. }
  332. BOOL CToolTipEx::OnMsg(MSG *pMsg)
  333. {
  334. if(FALSE == IsWindowVisible())
  335. {
  336. return FALSE;
  337. }
  338. switch(pMsg->message)
  339. {
  340. case WM_WINDOWPOSCHANGING:
  341. case WM_LBUTTONDOWN:
  342. {
  343. if (m_showPersistant == false)
  344. {
  345. if (CGetSetOptions::GetMouseClickHidesDescription())
  346. {
  347. if (!IsCursorInToolTip())
  348. {
  349. Hide();
  350. }
  351. }
  352. }
  353. }
  354. break;
  355. case WM_KEYDOWN:
  356. {
  357. WPARAM vk = pMsg->wParam;
  358. if(vk == VK_TAB)
  359. {
  360. m_RichEdit.SetFocus();
  361. return TRUE;
  362. }
  363. else if (vk == VK_CONTROL || vk == VK_SHIFT)
  364. {
  365. return FALSE;
  366. }
  367. else if (vk == VK_UP)
  368. {
  369. return FALSE;
  370. }
  371. else if (vk == VK_DOWN)
  372. {
  373. return FALSE;
  374. }
  375. else if (vk == VK_NEXT)
  376. {
  377. return FALSE;
  378. }
  379. else if (vk == VK_PRIOR)
  380. {
  381. return FALSE;
  382. }
  383. else if (vk == VK_DELETE)
  384. {
  385. return FALSE;
  386. }
  387. if (m_pToolTipActions != NULL)
  388. {
  389. if (m_pToolTipActions->ContainsKey((int)vk))
  390. {
  391. return FALSE;
  392. }
  393. }
  394. if (m_showPersistant == false)
  395. {
  396. Hide();
  397. }
  398. break;
  399. }
  400. case WM_LBUTTONDBLCLK:
  401. case WM_RBUTTONDBLCLK:
  402. case WM_MBUTTONDOWN:
  403. case WM_MBUTTONDBLCLK:
  404. case WM_NCLBUTTONDOWN:
  405. case WM_NCLBUTTONDBLCLK:
  406. case WM_NCRBUTTONDOWN:
  407. case WM_NCRBUTTONDBLCLK:
  408. case WM_NCMBUTTONDOWN:
  409. case WM_NCMBUTTONDBLCLK:
  410. {
  411. if (m_showPersistant == false)
  412. {
  413. Hide();
  414. }
  415. break;
  416. }
  417. case WM_MOUSEWHEEL:
  418. {
  419. if (m_imageViewer.m_pGdiplusBitmap)
  420. {
  421. m_imageViewer.PostMessageW(pMsg->message, pMsg->wParam, pMsg->lParam);
  422. return TRUE;
  423. }
  424. else
  425. {
  426. m_RichEdit.PostMessageW(pMsg->message, pMsg->wParam, pMsg->lParam);
  427. return TRUE;
  428. }
  429. }
  430. break;
  431. }
  432. return FALSE;
  433. }
  434. CRect CToolTipEx::GetBoundsRect()
  435. {
  436. DWORD d = GetTickCount();
  437. CWindowDC dc(NULL);
  438. int nLineWidth = 0;
  439. CRect rect(0, 0, 0, 0);
  440. if(nLineWidth == 0)
  441. {
  442. // Count the number of lines of text
  443. int nStart = 0;
  444. INT nNumLines = 0;
  445. int longestLength = 0;
  446. CString longestString;
  447. do
  448. {
  449. nNumLines++;
  450. int newStart = m_csText.Find(_T("\n"), nStart);
  451. if (newStart < 0)
  452. {
  453. int length = m_csText.GetLength() - nStart;
  454. if (length > longestLength)
  455. {
  456. longestString = m_csText.Mid(nStart, length);
  457. longestLength = length;
  458. }
  459. break;
  460. }
  461. int length = newStart - nStart;
  462. if(length > longestLength)
  463. {
  464. longestString = m_csText.Mid(nStart, length);
  465. longestLength = length;
  466. }
  467. nStart = newStart + 1;
  468. }
  469. while(nStart >= 0 && nNumLines < 100);
  470. CFont *pOldFont = (CFont*)dc.SelectObject((CFont*)&m_Font);
  471. CSize size = dc.GetTextExtent(longestString);
  472. dc.SelectObject(pOldFont);
  473. rect.right = size.cx;
  474. rect.bottom = size.cy * nNumLines;
  475. }
  476. rect.bottom += m_rectMargin.top + m_rectMargin.bottom;
  477. rect.right += m_rectMargin.left + m_rectMargin.right + 2;
  478. if(m_imageViewer.m_pGdiplusBitmap)
  479. {
  480. int nWidth = m_imageViewer.m_pGdiplusBitmap->GetWidth();
  481. int nHeight = m_imageViewer.m_pGdiplusBitmap->GetHeight();
  482. rect.bottom += nHeight;
  483. if((rect.left + nWidth) > rect.right)
  484. {
  485. rect.right = rect.left + nWidth;
  486. }
  487. }
  488. DWORD diff = GetTickCount() - d;
  489. if (diff > 10)
  490. {
  491. Log(StrF(_T("Size To Content: %d\n"), diff));
  492. }
  493. return rect;
  494. }
  495. CString CToolTipEx::GetFieldFromString(CString ref, int nIndex, TCHAR ch)
  496. {
  497. CString strReturn;
  498. LPCTSTR pstrStart = ref.LockBuffer();
  499. LPCTSTR pstrBuffer = pstrStart;
  500. int nCurrent = 0;
  501. int nStart = 0;
  502. int nEnd = 0;
  503. int nOldStart = 0;
  504. while(nCurrent <= nIndex && *pstrBuffer != _T('\0'))
  505. {
  506. if(*pstrBuffer == ch)
  507. {
  508. nOldStart = nStart;
  509. nStart = nEnd + 1;
  510. nCurrent++;
  511. }
  512. nEnd++;
  513. pstrBuffer++;
  514. }
  515. // May have reached the end of the string
  516. if(*pstrBuffer == _T('\0'))
  517. {
  518. nOldStart = nStart;
  519. nEnd++;
  520. }
  521. ref.UnlockBuffer();
  522. if(nCurrent < nIndex)
  523. {
  524. //TRACE1("Warning: GetStringField - Couldn't find field %d.\n", nIndex);
  525. return strReturn;
  526. }
  527. return ref.Mid(nOldStart, nEnd - nOldStart - 1);
  528. }
  529. BOOL CToolTipEx::SetLogFont(LPLOGFONT lpLogFont, BOOL bRedraw /*=TRUE*/)
  530. {
  531. ASSERT(lpLogFont);
  532. if(!lpLogFont)
  533. {
  534. return FALSE;
  535. }
  536. LOGFONT LogFont;
  537. // Store font as the global default
  538. memcpy(&LogFont, lpLogFont, sizeof(LOGFONT));
  539. m_fontHeight = lpLogFont->lfHeight;
  540. LogFont.lfHeight = m_DittoWindow.m_dpi.Scale(LogFont.lfHeight);
  541. // Create the actual font object
  542. m_Font.DeleteObject();
  543. m_Font.CreateFontIndirect(&LogFont);
  544. if(bRedraw && ::IsWindow(GetSafeHwnd()))
  545. {
  546. Invalidate();
  547. }
  548. return TRUE;
  549. }
  550. void CToolTipEx::SetGdiplusBitmap(Gdiplus::Bitmap *gdiplusBitmap)
  551. {
  552. delete m_imageViewer.m_pGdiplusBitmap;
  553. m_imageViewer.m_pGdiplusBitmap = NULL;
  554. m_imageViewer.m_pGdiplusBitmap = gdiplusBitmap;
  555. m_imageViewer.UpdateBitmapSize();
  556. Invalidate();
  557. }
  558. void CToolTipEx::OnSize(UINT nType, int cx, int cy)
  559. {
  560. CWnd::OnSize(nType, cx, cy);
  561. if(::IsWindow(m_RichEdit.GetSafeHwnd()) == FALSE)
  562. {
  563. return ;
  564. }
  565. MoveControls();
  566. }
  567. void CToolTipEx::MoveControls()
  568. {
  569. CRect cr;
  570. GetClientRect(cr);
  571. int bottom = 22;
  572. if (m_folderPath != _T(""))
  573. {
  574. bottom += m_DittoWindow.m_dpi.Scale(17);
  575. m_folderPathStatic.ShowWindow(SW_SHOW); }
  576. else
  577. {
  578. m_folderPathStatic.ShowWindow(SW_HIDE);
  579. }
  580. cr.DeflateRect(0, 0, 0, bottom);
  581. m_RichEdit.MoveWindow(cr);
  582. m_imageViewer.MoveWindow(cr);
  583. if (::IsWindow(m_browser.m_hWnd))
  584. {
  585. m_browser.MoveWindow(cr);
  586. }
  587. m_optionsButton.MoveWindow(cr.left, cr.bottom + m_DittoWindow.m_dpi.Scale(3), m_DittoWindow.m_dpi.Scale(17), m_DittoWindow.m_dpi.Scale(17));
  588. m_clipDataStatic.MoveWindow(cr.left + m_DittoWindow.m_dpi.Scale(19), cr.bottom + m_DittoWindow.m_dpi.Scale(4), cr.Width() - cr.left + m_DittoWindow.m_dpi.Scale(19), m_DittoWindow.m_dpi.Scale(20));
  589. m_folderPathStatic.MoveWindow(cr.left + m_DittoWindow.m_dpi.Scale(19), cr.bottom + m_DittoWindow.m_dpi.Scale(20), cr.Width() - cr.left + m_DittoWindow.m_dpi.Scale(19), m_DittoWindow.m_dpi.Scale(20));
  590. this->Invalidate();
  591. if (m_saveWindowLockout == false)
  592. {
  593. SetTimer(SAVE_SIZE, 250, NULL);
  594. }
  595. }
  596. BOOL CToolTipEx::IsCursorInToolTip()
  597. {
  598. CRect cr;
  599. GetWindowRect(cr);
  600. CPoint cursorPos;
  601. GetCursorPos(&cursorPos);
  602. return cr.PtInRect(cursorPos);
  603. }
  604. void CToolTipEx::SetHtmlText(const CString &html)
  605. {
  606. if (html.GetLength() > 0 &&
  607. ::IsWindow(m_browser.m_hWnd) == FALSE)
  608. {
  609. m_browser.Create(WS_CHILD | WS_VISIBLE, CRect(10, 10, 100, 200), this, 2);
  610. }
  611. if (::IsWindow(m_browser.m_hWnd))
  612. {
  613. int pos = html.Find(_T("<html"));
  614. if (pos >= 0)
  615. {
  616. m_html = html.Mid(pos);
  617. }
  618. else
  619. {
  620. m_html = html;
  621. }
  622. COLORREF c = g_Opt.m_Theme.DescriptionWindowBG();
  623. DWORD dwR = GetRValue(c);
  624. DWORD dwG = GetGValue(c);
  625. DWORD dwB = GetBValue(c);
  626. CString colorHex;
  627. colorHex.Format(_T("#%02X%02X%02X"), dwR, dwG, dwB);
  628. m_html.Replace(_T("<body>"), StrF(_T("<body bgcolor=\"%s\">"), colorHex));
  629. m_browser.PutSilent(true);
  630. m_browser.Clear();
  631. m_browser.Write(m_html);
  632. }
  633. }
  634. void CToolTipEx::SetRTFText(const char *pRTF)
  635. {
  636. m_RichEdit.SetRTF(pRTF);
  637. m_csRTF = pRTF;
  638. m_RichEdit.SetSel(0, 0);
  639. HighlightSearchText();
  640. }
  641. //void CToolTipEx::SetRTFText(const CString &csRTF)
  642. //{
  643. // m_RichEdit.SetRTF(csRTF);
  644. // m_csRTF = csRTF;
  645. //}
  646. void CToolTipEx::SetToolTipText(const CString &csText)
  647. {
  648. m_csText = csText;
  649. m_RichEdit.SetFont(&m_Font);
  650. m_RichEdit.SetText(csText);
  651. m_RichEdit.SetSel(0, 0);
  652. CHARFORMAT cfNew;
  653. cfNew.cbSize = sizeof(CHARFORMAT);
  654. cfNew.dwMask = CFM_COLOR;
  655. cfNew.dwEffects = CFM_COLOR;
  656. cfNew.dwEffects &= ~CFE_AUTOCOLOR;
  657. cfNew.crTextColor = g_Opt.m_Theme.DescriptionWindowText();
  658. m_RichEdit.SetDefaultCharFormat(cfNew);
  659. HighlightSearchText();
  660. }
  661. void CToolTipEx::HighlightSearchText()
  662. {
  663. if (m_searchText.GetLength() <= 0)
  664. return;
  665. FINDTEXTEX ft;
  666. long n = -1;
  667. ft.lpstrText = m_searchText;
  668. ft.chrg.cpMin = 0;
  669. ft.chrg.cpMax = -1;
  670. CHARFORMAT cf;
  671. cf.cbSize = sizeof(cf);
  672. cf.dwMask = CFM_COLOR;
  673. cf.dwEffects = CFE_BOLD | ~CFE_AUTOCOLOR;
  674. cf.crTextColor = RGB(255, 0, 0);
  675. do
  676. {
  677. ft.chrg.cpMin = n+1;
  678. n = m_RichEdit.FindText(FR_DOWN, &ft);
  679. if (n != -1)
  680. {
  681. m_RichEdit.SetSel(ft.chrgText);
  682. m_RichEdit.SetSelectionCharFormat(cf);
  683. }
  684. } while (n != -1);
  685. m_RichEdit.SetSel(0, 0);
  686. }
  687. void CToolTipEx::DoSearch()
  688. {
  689. if (m_searchText.GetLength() <= 0)
  690. return;
  691. FINDTEXTEX ft;
  692. long n = -1;
  693. ft.lpstrText = m_searchText;
  694. long start;
  695. long end;
  696. m_RichEdit.GetSel(start, end);
  697. ft.chrg.cpMin = end;
  698. ft.chrg.cpMax = -1;
  699. int searchDirection = FR_DOWN;
  700. if (GetKeyState(VK_SHIFT) & 0x8000)
  701. {
  702. searchDirection = 0;
  703. ft.chrg.cpMin = start;
  704. }
  705. n = m_RichEdit.FindText(searchDirection, &ft);
  706. if (n != -1)
  707. {
  708. m_RichEdit.SetSel(ft.chrgText);
  709. }
  710. else
  711. {
  712. if (searchDirection == 0)
  713. {
  714. ft.chrg.cpMin = m_RichEdit.GetTextLength();
  715. }
  716. else
  717. {
  718. ft.chrg.cpMin = 0;
  719. }
  720. ft.chrg.cpMax = -1;
  721. n = m_RichEdit.FindText(searchDirection, &ft);
  722. if (n != -1)
  723. {
  724. m_RichEdit.SetSel(ft.chrgText);
  725. }
  726. }
  727. }
  728. void CToolTipEx::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
  729. {
  730. CWnd::OnActivate(nState, pWndOther, bMinimized);
  731. if (nState == WA_INACTIVE)
  732. {
  733. if(m_pNotifyWnd)
  734. {
  735. m_pNotifyWnd->PostMessage(NM_INACTIVE_TOOLTIPWND, 0, 0);
  736. }
  737. }
  738. }
  739. void CToolTipEx::OnTimer(UINT_PTR nIDEvent)
  740. {
  741. switch(nIDEvent)
  742. {
  743. case HIDE_WINDOW_TIMER:
  744. Hide();
  745. PostMessage(WM_DESTROY, 0, 0);
  746. break;
  747. case SAVE_SIZE:
  748. SaveWindowSize();
  749. KillTimer(SAVE_SIZE);
  750. break;
  751. case TIMER_BUTTON_UP:
  752. {
  753. if ((GetKeyState(VK_LBUTTON) & 0x100) == 0)
  754. {
  755. m_DittoWindow.DoNcLButtonUp(this, 0, CPoint(0, 0));
  756. KillTimer(TIMER_BUTTON_UP);
  757. }
  758. break;
  759. }
  760. case TIMER_AUTO_MAX:
  761. {
  762. if (m_DittoWindow.m_bMinimized)
  763. {
  764. CPoint cp;
  765. GetCursorPos(&cp);
  766. UINT nHitTest = (UINT)OnNcHitTest(cp);
  767. ScreenToClient(&cp);
  768. if (nHitTest == HTCAPTION)
  769. {
  770. if (m_DittoWindow.m_crCloseBT.PtInRect(cp) == false)
  771. {
  772. if (m_DittoWindow.m_crMinimizeBT.PtInRect(cp) == false)
  773. {
  774. m_DittoWindow.MinMaxWindow(this, FORCE_MAX);
  775. }
  776. }
  777. }
  778. }
  779. KillTimer(TIMER_AUTO_MAX);
  780. m_bMaxSetTimer = false;
  781. }
  782. }
  783. CWnd::OnTimer(nIDEvent);
  784. }
  785. void CToolTipEx::OnNcPaint()
  786. {
  787. m_DittoWindow.DoNcPaint(this);
  788. }
  789. void CToolTipEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
  790. {
  791. CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
  792. m_DittoWindow.DoNcCalcSize(bCalcValidRects, lpncsp);
  793. }
  794. HITTEST_RET CToolTipEx::OnNcHitTest(CPoint point)
  795. {
  796. UINT Ret = m_DittoWindow.DoNcHitTest(this, point);
  797. if(Ret == -1)
  798. return CWnd::OnNcHitTest(point);
  799. return Ret;
  800. }
  801. void CToolTipEx::OnNcLButtonDown(UINT nHitTest, CPoint point)
  802. {
  803. int buttonPressed = m_DittoWindow.DoNcLButtonDown(this, nHitTest, point);
  804. if (buttonPressed != 0)
  805. {
  806. SetTimer(TIMER_BUTTON_UP, 100, NULL);
  807. }
  808. CWnd::OnNcLButtonDown(nHitTest, point);
  809. }
  810. void CToolTipEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
  811. {
  812. long lRet = m_DittoWindow.DoNcLButtonUp(this, nHitTest, point);
  813. switch(lRet)
  814. {
  815. case BUTTON_CLOSE:
  816. Hide();
  817. break;
  818. case BUTTON_CHEVRON:
  819. m_DittoWindow.MinMaxWindow(this, SWAP_MIN_MAX);
  820. OnNcPaint();
  821. break;
  822. }
  823. KillTimer(TIMER_BUTTON_UP);
  824. CWnd::OnNcLButtonUp(nHitTest, point);
  825. }
  826. void CToolTipEx::OnNcMouseMove(UINT nHitTest, CPoint point)
  827. {
  828. m_DittoWindow.DoNcMouseMove(this, nHitTest, point);
  829. if ((m_bMaxSetTimer == false) && m_DittoWindow.m_bMinimized)
  830. {
  831. COleDateTimeSpan sp = COleDateTime::GetCurrentTime() - m_DittoWindow.m_TimeMinimized;
  832. if (sp.GetTotalSeconds() >= m_lDelayMaxSeconds)
  833. {
  834. SetTimer(TIMER_AUTO_MAX, CGetSetOptions::GetTimeBeforeExpandWindow(), NULL);
  835. m_bMaxSetTimer = true;
  836. }
  837. }
  838. CWnd::OnNcMouseMove(nHitTest, point);
  839. }
  840. void CToolTipEx::OnOptions()
  841. {
  842. POINT pp;
  843. CMenu cmPopUp;
  844. CMenu *cmSubMenu = NULL;
  845. GetCursorPos(&pp);
  846. if(cmPopUp.LoadMenu(IDR_DESC_OPTIONS_MENU) != 0)
  847. {
  848. cmSubMenu = cmPopUp.GetSubMenu(0);
  849. if(!cmSubMenu)
  850. {
  851. return ;
  852. }
  853. GetCursorPos(&pp);
  854. //theApp.m_Language.UpdateRightClickMenu(cmSubMenu);
  855. if(CGetSetOptions::GetRememberDescPos())
  856. cmSubMenu->CheckMenuItem(ID_FIRST_REMEMBERWINDOWPOSITION, MF_CHECKED);
  857. if(CGetSetOptions::GetSizeDescWindowToContent())
  858. cmSubMenu->CheckMenuItem(ID_FIRST_SIZEWINDOWTOCONTENT, MF_CHECKED);
  859. if(CGetSetOptions::GetScaleImagesToDescWindow())
  860. cmSubMenu->CheckMenuItem(ID_FIRST_SCALEIMAGESTOFITWINDOW, MF_CHECKED);
  861. if (CGetSetOptions::GetMouseClickHidesDescription())
  862. cmSubMenu->CheckMenuItem(ID_FIRST_HIDEDESCRIPTIONWINDOWONM, MF_CHECKED);
  863. if (CGetSetOptions::GetWrapDescriptionText())
  864. cmSubMenu->CheckMenuItem(ID_FIRST_WRAPTEXT, MF_CHECKED);
  865. if (m_showPersistant)
  866. cmSubMenu->CheckMenuItem(ID_FIRST_ALWAYSONTOP, MF_CHECKED);
  867. UpdateMenuShortCut(cmSubMenu, ID_FIRST_WRAPTEXT, ActionEnums::TOGGLE_DESCRIPTION_WORD_WRAP);
  868. UpdateMenuShortCut(cmSubMenu, ID_FIRST_ALWAYSONTOP, ActionEnums::TOGGLESHOWPERSISTANT);
  869. cmSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, pp.x, pp.y, this, NULL);
  870. }
  871. }
  872. void CToolTipEx::UpdateMenuShortCut(CMenu *subMenu, int id, DWORD action)
  873. {
  874. if (m_pToolTipActions != NULL)
  875. {
  876. CString cs;
  877. subMenu->GetMenuString(id, cs, MF_BYCOMMAND);
  878. CString shortcutText = m_pToolTipActions->GetCmdKeyText(action);
  879. if (shortcutText != _T("") &&
  880. cs.Find("\t" + shortcutText) < 0)
  881. {
  882. cs += "\t";
  883. cs += shortcutText;
  884. subMenu->ModifyMenu(id, MF_BYCOMMAND, id, cs);
  885. }
  886. }
  887. }
  888. void CToolTipEx::OnRememberwindowposition()
  889. {
  890. CGetSetOptions::SetRememberDescPos(!CGetSetOptions::GetRememberDescPos());
  891. }
  892. void CToolTipEx::OnSizewindowtocontent()
  893. {
  894. CGetSetOptions::SetSizeDescWindowToContent(!CGetSetOptions::GetSizeDescWindowToContent());
  895. CRect rect;
  896. this->GetWindowRect(&rect);
  897. Show(rect.TopLeft());
  898. }
  899. void CToolTipEx::OnScaleimagestofitwindow()
  900. {
  901. CGetSetOptions::SetScaleImagesToDescWindow(!CGetSetOptions::GetScaleImagesToDescWindow());
  902. m_imageViewer.UpdateBitmapSize();
  903. Invalidate();
  904. }
  905. void CToolTipEx::OnRButtonDown(UINT nFlags, CPoint point)
  906. {
  907. OnOptions();
  908. CWnd::OnRButtonDown(nFlags, point);
  909. }
  910. void CToolTipEx::OnSetFocus(CWnd* pOldWnd)
  911. {
  912. CWnd::OnSetFocus(pOldWnd);
  913. m_RichEdit.SetFocus();
  914. }
  915. void CToolTipEx::OnPaint()
  916. {
  917. CPaintDC dc(this); // device context for painting
  918. CRect rect;
  919. GetClientRect(rect);
  920. CBrush Brush, *pOldBrush;
  921. Brush.CreateSolidBrush(g_Opt.m_Theme.DescriptionWindowBG());
  922. pOldBrush = dc.SelectObject(&Brush);
  923. dc.FillRect(&rect, &Brush);
  924. // Cleanup
  925. dc.SelectObject(pOldBrush);
  926. }
  927. void CToolTipEx::OnFirstHidedescriptionwindowonm()
  928. {
  929. CGetSetOptions::SetMouseClickHidesDescription(!CGetSetOptions::GetMouseClickHidesDescription());
  930. }
  931. bool CToolTipEx::ToggleWordWrap()
  932. {
  933. bool didWordWrap = false;
  934. if (m_RichEdit.IsWindowVisible())
  935. {
  936. OnFirstWraptext();
  937. didWordWrap = true;
  938. }
  939. return didWordWrap;
  940. }
  941. void CToolTipEx::OnFirstWraptext()
  942. {
  943. CGetSetOptions::SetWrapDescriptionText(!CGetSetOptions::GetWrapDescriptionText());
  944. ApplyWordWrap();
  945. }
  946. void CToolTipEx::ApplyWordWrap()
  947. {
  948. if (CGetSetOptions::GetWrapDescriptionText())
  949. {
  950. m_RichEdit.SetTargetDevice(NULL, 0);
  951. }
  952. else
  953. {
  954. m_RichEdit.SetTargetDevice(NULL, 1);
  955. }
  956. }
  957. void CToolTipEx::HideWindowInXMilliSeconds(long lms)
  958. {
  959. SetTimer(HIDE_WINDOW_TIMER, lms, NULL);
  960. }
  961. void CToolTipEx::OnWindowPosChanging(WINDOWPOS* lpwndpos)
  962. {
  963. CWnd::OnWindowPosChanging(lpwndpos);
  964. //m_DittoWindow.SnapToEdge(this, lpwndpos);
  965. }
  966. void CToolTipEx::OnFirstAlwaysontop()
  967. {
  968. m_showPersistant = !m_showPersistant;
  969. if (m_showPersistant)
  970. {
  971. m_DittoWindow.m_customWindowTitle = _T("[Always on top]");
  972. m_DittoWindow.m_useCustomWindowTitle = true;
  973. ::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE);
  974. }
  975. else
  976. {
  977. m_DittoWindow.m_customWindowTitle = _T("");
  978. m_DittoWindow.m_useCustomWindowTitle = true;
  979. }
  980. ::SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
  981. }
  982. BOOL CToolTipEx::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  983. {
  984. CString cs;
  985. cs.Format(_T("On Notify: %d\r\n"), ((LPNMHDR)lParam)->code);
  986. OutputDebugString(cs);
  987. switch (((LPNMHDR)lParam)->code)
  988. {
  989. case EN_LINK:
  990. {
  991. ENLINK *enLinkInfo = (ENLINK *)lParam; // pointer to a ENLINK structure
  992. if (enLinkInfo->msg == WM_LBUTTONUP)
  993. {
  994. CString s;
  995. m_RichEdit.GetTextRange(enLinkInfo->chrg.cpMin, enLinkInfo->chrg.cpMax, s);
  996. if (s == m_mouseDownOnLink)
  997. {
  998. CHyperLink::GotoURL(s, SW_SHOW);
  999. }
  1000. m_mouseDownOnLink = _T("");
  1001. }
  1002. if (enLinkInfo->msg == WM_LBUTTONDOWN)
  1003. {
  1004. m_RichEdit.GetTextRange(enLinkInfo->chrg.cpMin, enLinkInfo->chrg.cpMax, m_mouseDownOnLink);
  1005. }
  1006. }
  1007. break;
  1008. case SimpleBrowser::NotificationType::BeforeNavigate2:
  1009. {
  1010. SimpleBrowser::Notification * not = (SimpleBrowser::Notification *)lParam;
  1011. if (not != NULL)
  1012. {
  1013. if (not->URL.Find(_T("http")) >= 0)
  1014. {
  1015. CHyperLink::GotoURL(not->URL, SW_SHOW);
  1016. *pResult = TRUE;
  1017. //return TRUE;
  1018. }
  1019. }
  1020. }
  1021. break;
  1022. case 5:
  1023. int x = 0;
  1024. break;
  1025. }
  1026. return CWnd::OnNotify(wParam, lParam, pResult);
  1027. }
  1028. void CToolTipEx::OnEnMsgfilterRichedit21(NMHDR *pNMHDR, LRESULT *pResult)
  1029. {
  1030. MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
  1031. if (pMsgFilter != NULL)
  1032. {
  1033. switch (pMsgFilter->msg)
  1034. {
  1035. //handle click on the rich text control when it doesn't have focus
  1036. //set focus so the first click is handled by the rich text control
  1037. case WM_MOUSEACTIVATE:
  1038. m_RichEdit.SetFocus();
  1039. break;
  1040. }
  1041. }
  1042. *pResult = 0;
  1043. }
  1044. LRESULT CToolTipEx::OnDpiChanged(WPARAM wParam, LPARAM lParam)
  1045. {
  1046. int dpi = HIWORD(wParam);
  1047. m_DittoWindow.OnDpiChanged(this, dpi);
  1048. RECT* const prcNewWindow = (RECT*)lParam;
  1049. SetWindowPos(NULL,
  1050. prcNewWindow->left,
  1051. prcNewWindow->top,
  1052. prcNewWindow->right - prcNewWindow->left,
  1053. prcNewWindow->bottom - prcNewWindow->top,
  1054. SWP_NOZORDER | SWP_NOACTIVATE);
  1055. m_optionsButton.Reset();
  1056. m_optionsButton.LoadStdImageDPI(m_DittoWindow.m_dpi.GetDPI(), IDB_COG_16_16, IDB_COG_20_20, IDB_COG_24_24, cog_28, IDB_COG_32_32, _T("PNG"));
  1057. m_clipDataFont.Detach();
  1058. m_clipDataFont.CreateFont(-m_DittoWindow.m_dpi.Scale(8), 0, 0, 0, 400, 0, 0, 0, DEFAULT_CHARSET, 3, 2, 1, 34, _T("Segoe UI"));
  1059. m_clipDataStatic.SetFont(&m_clipDataFont);
  1060. m_clipDataStatic.SetBkColor(g_Opt.m_Theme.DescriptionWindowBG());
  1061. m_clipDataStatic.SetTextColor(RGB(80, 80, 80));
  1062. m_folderPathStatic.SetFont(&m_clipDataFont);
  1063. m_folderPathStatic.SetBkColor(g_Opt.m_Theme.DescriptionWindowBG());
  1064. m_folderPathStatic.SetTextColor(RGB(80, 80, 80));
  1065. LOGFONT lf;
  1066. m_Font.GetLogFont(&lf);
  1067. lf.lfHeight = m_DittoWindow.m_dpi.Scale(m_fontHeight);
  1068. // Create the actual font object
  1069. m_Font.DeleteObject();
  1070. m_Font.CreateFontIndirect(&lf);
  1071. m_RichEdit.SetFont(&m_Font);
  1072. this->MoveControls();
  1073. this->Invalidate();
  1074. this->UpdateWindow();
  1075. return TRUE;
  1076. }
  1077. void CToolTipEx::OnMoving(UINT fwSide, LPRECT pRect)
  1078. {
  1079. CWnd::OnMoving(fwSide, pRect);
  1080. m_snap.OnSnapMoving(m_hWnd, pRect);
  1081. // TODO: Add your message handler code here
  1082. }
  1083. void CToolTipEx::OnEnterSizeMove()
  1084. {
  1085. m_snap.OnSnapEnterSizeMove(m_hWnd);
  1086. CWnd::OnEnterSizeMove();
  1087. }