ToolTipEx.cpp 31 KB

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