ToolTipEx.cpp 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  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. if(m_imageViewer.m_pGdiplusBitmap)
  116. {
  117. m_clipData += _T(" | ") + StrF(_T("%d x %d"), m_imageViewer.m_pGdiplusBitmap->GetWidth(), m_imageViewer.m_pGdiplusBitmap->GetHeight());
  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. ClientToScreen(rect);
  180. CRect cr(point, point);
  181. CRect rcScreen = MonitorRectFromRect(cr);
  182. //ensure that we don't go outside the screen
  183. if(point.x < 0)
  184. {
  185. point.x = 5;
  186. //m_reducedWindowSize = true;
  187. }
  188. if(point.y < 0)
  189. {
  190. point.y = 5;
  191. //m_reducedWindowSize = true;
  192. }
  193. rcScreen.DeflateRect(0, 0, 5, 5);
  194. long lWidth = rect.Width();
  195. long lHeight = rect.Height();
  196. rect.left = point.x;
  197. rect.top = point.y;
  198. rect.right = rect.left + lWidth;
  199. rect.bottom = rect.top + lHeight;
  200. if (rect.right > rcScreen.right)
  201. {
  202. rect.right = rcScreen.right;
  203. //m_reducedWindowSize = true;
  204. }
  205. if (rect.bottom > rcScreen.bottom)
  206. {
  207. rect.bottom = rcScreen.bottom;
  208. //m_reducedWindowSize = true;
  209. }
  210. }
  211. m_clipDataStatic.SetWindowText(m_clipData);
  212. m_folderPathStatic.SetWindowText(m_folderPath);
  213. if (m_DittoWindow.m_bMinimized)
  214. {
  215. //m_DittoWindow.MinMaxWindow(this, FORCE_MAX);
  216. m_DittoWindow.m_bMinimized = false;
  217. }
  218. m_saveWindowLockout = true;
  219. MoveWindow(rect);
  220. ShowWindow(SW_SHOWNA);
  221. this->Invalidate();
  222. this->UpdateWindow();
  223. MoveControls();
  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. case WM_MOUSEHWHEEL:
  419. {
  420. if (m_imageViewer.m_pGdiplusBitmap)
  421. {
  422. m_imageViewer.PostMessageW(pMsg->message, pMsg->wParam, pMsg->lParam);
  423. return TRUE;
  424. }
  425. else
  426. {
  427. m_RichEdit.PostMessageW(pMsg->message, pMsg->wParam, pMsg->lParam);
  428. return TRUE;
  429. }
  430. }
  431. break;
  432. }
  433. return FALSE;
  434. }
  435. CRect CToolTipEx::GetBoundsRect()
  436. {
  437. DWORD d = GetTickCount();
  438. CWindowDC dc(NULL);
  439. int nLineWidth = 0;
  440. CRect rect(0, 0, 0, 0);
  441. if(nLineWidth == 0)
  442. {
  443. // Count the number of lines of text
  444. int nStart = 0;
  445. INT nNumLines = 0;
  446. int longestLength = 0;
  447. CString longestString;
  448. do
  449. {
  450. nNumLines++;
  451. int newStart = m_csText.Find(_T("\n"), nStart);
  452. if (newStart < 0)
  453. {
  454. int length = m_csText.GetLength() - nStart;
  455. if (length > longestLength)
  456. {
  457. longestString = m_csText.Mid(nStart, length);
  458. longestLength = length;
  459. }
  460. break;
  461. }
  462. int length = newStart - nStart;
  463. if(length > longestLength)
  464. {
  465. longestString = m_csText.Mid(nStart, length);
  466. longestLength = length;
  467. }
  468. nStart = newStart + 1;
  469. }
  470. while(nStart >= 0 && nNumLines < 100);
  471. CFont *pOldFont = (CFont*)dc.SelectObject((CFont*)&m_Font);
  472. CSize size = dc.GetTextExtent(longestString);
  473. dc.SelectObject(pOldFont);
  474. rect.right = size.cx;
  475. rect.bottom = size.cy * nNumLines;
  476. }
  477. rect.bottom += m_rectMargin.top + m_rectMargin.bottom;
  478. rect.right += m_rectMargin.left + m_rectMargin.right + 2;
  479. if(m_imageViewer.m_pGdiplusBitmap)
  480. {
  481. int nWidth = m_imageViewer.m_pGdiplusBitmap->GetWidth();
  482. int nHeight = m_imageViewer.m_pGdiplusBitmap->GetHeight();
  483. rect.bottom += nHeight;
  484. if((rect.left + nWidth) > rect.right)
  485. {
  486. rect.right = rect.left + nWidth;
  487. }
  488. }
  489. DWORD diff = GetTickCount() - d;
  490. if (diff > 10)
  491. {
  492. Log(StrF(_T("Size To Content: %d\n"), diff));
  493. }
  494. return rect;
  495. }
  496. CString CToolTipEx::GetFieldFromString(CString ref, int nIndex, TCHAR ch)
  497. {
  498. CString strReturn;
  499. LPCTSTR pstrStart = ref.LockBuffer();
  500. LPCTSTR pstrBuffer = pstrStart;
  501. int nCurrent = 0;
  502. int nStart = 0;
  503. int nEnd = 0;
  504. int nOldStart = 0;
  505. while(nCurrent <= nIndex && *pstrBuffer != _T('\0'))
  506. {
  507. if(*pstrBuffer == ch)
  508. {
  509. nOldStart = nStart;
  510. nStart = nEnd + 1;
  511. nCurrent++;
  512. }
  513. nEnd++;
  514. pstrBuffer++;
  515. }
  516. // May have reached the end of the string
  517. if(*pstrBuffer == _T('\0'))
  518. {
  519. nOldStart = nStart;
  520. nEnd++;
  521. }
  522. ref.UnlockBuffer();
  523. if(nCurrent < nIndex)
  524. {
  525. //TRACE1("Warning: GetStringField - Couldn't find field %d.\n", nIndex);
  526. return strReturn;
  527. }
  528. return ref.Mid(nOldStart, nEnd - nOldStart - 1);
  529. }
  530. BOOL CToolTipEx::SetLogFont(LPLOGFONT lpLogFont, BOOL bRedraw /*=TRUE*/)
  531. {
  532. ASSERT(lpLogFont);
  533. if(!lpLogFont)
  534. {
  535. return FALSE;
  536. }
  537. LOGFONT LogFont;
  538. // Store font as the global default
  539. memcpy(&LogFont, lpLogFont, sizeof(LOGFONT));
  540. m_fontHeight = lpLogFont->lfHeight;
  541. LogFont.lfHeight = m_DittoWindow.m_dpi.Scale(LogFont.lfHeight);
  542. // Create the actual font object
  543. m_Font.DeleteObject();
  544. m_Font.CreateFontIndirect(&LogFont);
  545. if(bRedraw && ::IsWindow(GetSafeHwnd()))
  546. {
  547. Invalidate();
  548. }
  549. return TRUE;
  550. }
  551. void CToolTipEx::SetGdiplusBitmap(Gdiplus::Bitmap *gdiplusBitmap)
  552. {
  553. delete m_imageViewer.m_pGdiplusBitmap;
  554. m_imageViewer.m_pGdiplusBitmap = NULL;
  555. m_imageViewer.m_pGdiplusBitmap = gdiplusBitmap;
  556. m_imageViewer.UpdateBitmapSize();
  557. Invalidate();
  558. }
  559. void CToolTipEx::OnSize(UINT nType, int cx, int cy)
  560. {
  561. CWnd::OnSize(nType, cx, cy);
  562. if(::IsWindow(m_RichEdit.GetSafeHwnd()) == FALSE)
  563. {
  564. return ;
  565. }
  566. MoveControls();
  567. }
  568. void CToolTipEx::MoveControls()
  569. {
  570. CRect cr;
  571. GetClientRect(cr);
  572. int bottom = m_DittoWindow.m_dpi.Scale(22);
  573. int optionsExtra = 0;
  574. if (m_folderPath != _T(""))
  575. {
  576. bottom += m_DittoWindow.m_dpi.Scale(17);
  577. optionsExtra += m_DittoWindow.m_dpi.Scale(10);
  578. m_folderPathStatic.ShowWindow(SW_SHOW);
  579. }
  580. else
  581. {
  582. m_folderPathStatic.ShowWindow(SW_HIDE);
  583. }
  584. cr.DeflateRect(0, 0, 0, bottom);
  585. m_RichEdit.MoveWindow(cr);
  586. m_imageViewer.MoveWindow(cr);
  587. if (::IsWindow(m_browser.m_hWnd))
  588. {
  589. m_browser.MoveWindow(cr);
  590. }
  591. m_optionsButton.MoveWindow(cr.left, cr.bottom + m_DittoWindow.m_dpi.Scale(3) + optionsExtra, m_DittoWindow.m_dpi.Scale(17), m_DittoWindow.m_dpi.Scale(17));
  592. 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));
  593. 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));
  594. this->Invalidate();
  595. if (m_saveWindowLockout == false)
  596. {
  597. SetTimer(SAVE_SIZE, 250, NULL);
  598. }
  599. }
  600. BOOL CToolTipEx::IsCursorInToolTip()
  601. {
  602. CRect cr;
  603. GetWindowRect(cr);
  604. CPoint cursorPos;
  605. GetCursorPos(&cursorPos);
  606. return cr.PtInRect(cursorPos);
  607. }
  608. void CToolTipEx::SetHtmlText(const CString &html)
  609. {
  610. if (html.GetLength() > 0 &&
  611. ::IsWindow(m_browser.m_hWnd) == FALSE)
  612. {
  613. m_browser.Create(WS_CHILD | WS_VISIBLE, CRect(10, 10, 100, 200), this, 2);
  614. }
  615. if (::IsWindow(m_browser.m_hWnd))
  616. {
  617. int pos = html.Find(_T("<html"));
  618. if (pos >= 0)
  619. {
  620. m_html = html.Mid(pos);
  621. }
  622. else
  623. {
  624. m_html = html;
  625. }
  626. COLORREF c = g_Opt.m_Theme.DescriptionWindowBG();
  627. DWORD dwR = GetRValue(c);
  628. DWORD dwG = GetGValue(c);
  629. DWORD dwB = GetBValue(c);
  630. CString colorHex;
  631. colorHex.Format(_T("#%02X%02X%02X"), dwR, dwG, dwB);
  632. m_html.Replace(_T("<body>"), StrF(_T("<body bgcolor=\"%s\">"), colorHex));
  633. m_browser.PutSilent(true);
  634. m_browser.Clear();
  635. m_browser.Write(m_html);
  636. }
  637. }
  638. void CToolTipEx::SetRTFText(const char *pRTF)
  639. {
  640. m_RichEdit.SetRTF(pRTF);
  641. m_csRTF = pRTF;
  642. m_RichEdit.SetSel(0, 0);
  643. HighlightSearchText();
  644. }
  645. //void CToolTipEx::SetRTFText(const CString &csRTF)
  646. //{
  647. // m_RichEdit.SetRTF(csRTF);
  648. // m_csRTF = csRTF;
  649. //}
  650. void CToolTipEx::SetToolTipText(const CString &csText)
  651. {
  652. m_csText = csText;
  653. m_RichEdit.SetFont(&m_Font);
  654. m_RichEdit.SetText(csText);
  655. m_RichEdit.SetSel(0, 0);
  656. CHARFORMAT cfNew;
  657. cfNew.cbSize = sizeof(CHARFORMAT);
  658. cfNew.dwMask = CFM_COLOR;
  659. cfNew.dwEffects = CFM_COLOR;
  660. cfNew.dwEffects &= ~CFE_AUTOCOLOR;
  661. cfNew.crTextColor = g_Opt.m_Theme.DescriptionWindowText();
  662. m_RichEdit.SetDefaultCharFormat(cfNew);
  663. HighlightSearchText();
  664. }
  665. void CToolTipEx::HighlightSearchText()
  666. {
  667. if (m_searchText.GetLength() <= 0)
  668. return;
  669. FINDTEXTEX ft;
  670. long n = -1;
  671. ft.lpstrText = m_searchText;
  672. ft.chrg.cpMin = 0;
  673. ft.chrg.cpMax = -1;
  674. CHARFORMAT cf;
  675. cf.cbSize = sizeof(cf);
  676. cf.dwMask = CFM_COLOR;
  677. cf.dwEffects = CFE_BOLD | ~CFE_AUTOCOLOR;
  678. cf.crTextColor = RGB(255, 0, 0);
  679. do
  680. {
  681. ft.chrg.cpMin = n+1;
  682. n = m_RichEdit.FindText(FR_DOWN, &ft);
  683. if (n != -1)
  684. {
  685. m_RichEdit.SetSel(ft.chrgText);
  686. m_RichEdit.SetSelectionCharFormat(cf);
  687. }
  688. } while (n != -1);
  689. m_RichEdit.SetSel(0, 0);
  690. }
  691. void CToolTipEx::DoSearch()
  692. {
  693. if (m_searchText.GetLength() <= 0)
  694. return;
  695. FINDTEXTEX ft;
  696. long n = -1;
  697. ft.lpstrText = m_searchText;
  698. long start;
  699. long end;
  700. m_RichEdit.GetSel(start, end);
  701. ft.chrg.cpMin = end;
  702. ft.chrg.cpMax = -1;
  703. int searchDirection = FR_DOWN;
  704. if (GetKeyState(VK_SHIFT) & 0x8000)
  705. {
  706. searchDirection = 0;
  707. ft.chrg.cpMin = start;
  708. }
  709. n = m_RichEdit.FindText(searchDirection, &ft);
  710. if (n != -1)
  711. {
  712. m_RichEdit.SetSel(ft.chrgText);
  713. }
  714. else
  715. {
  716. if (searchDirection == 0)
  717. {
  718. ft.chrg.cpMin = m_RichEdit.GetTextLength();
  719. }
  720. else
  721. {
  722. ft.chrg.cpMin = 0;
  723. }
  724. ft.chrg.cpMax = -1;
  725. n = m_RichEdit.FindText(searchDirection, &ft);
  726. if (n != -1)
  727. {
  728. m_RichEdit.SetSel(ft.chrgText);
  729. }
  730. }
  731. }
  732. void CToolTipEx::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
  733. {
  734. CWnd::OnActivate(nState, pWndOther, bMinimized);
  735. if (nState == WA_INACTIVE)
  736. {
  737. if(m_pNotifyWnd)
  738. {
  739. m_pNotifyWnd->PostMessage(NM_INACTIVE_TOOLTIPWND, 0, 0);
  740. }
  741. }
  742. }
  743. void CToolTipEx::OnTimer(UINT_PTR nIDEvent)
  744. {
  745. switch(nIDEvent)
  746. {
  747. case HIDE_WINDOW_TIMER:
  748. Hide();
  749. PostMessage(WM_DESTROY, 0, 0);
  750. break;
  751. case SAVE_SIZE:
  752. SaveWindowSize();
  753. KillTimer(SAVE_SIZE);
  754. break;
  755. case TIMER_BUTTON_UP:
  756. {
  757. if ((GetKeyState(VK_LBUTTON) & 0x100) == 0)
  758. {
  759. m_DittoWindow.DoNcLButtonUp(this, 0, CPoint(0, 0));
  760. KillTimer(TIMER_BUTTON_UP);
  761. }
  762. break;
  763. }
  764. case TIMER_AUTO_MAX:
  765. {
  766. if (m_DittoWindow.m_bMinimized)
  767. {
  768. CPoint cp;
  769. GetCursorPos(&cp);
  770. UINT nHitTest = (UINT)OnNcHitTest(cp);
  771. ScreenToClient(&cp);
  772. if (nHitTest == HTCAPTION)
  773. {
  774. if (m_DittoWindow.m_crCloseBT.PtInRect(cp) == false)
  775. {
  776. if (m_DittoWindow.m_crMinimizeBT.PtInRect(cp) == false)
  777. {
  778. m_DittoWindow.MinMaxWindow(this, FORCE_MAX);
  779. }
  780. }
  781. }
  782. }
  783. KillTimer(TIMER_AUTO_MAX);
  784. m_bMaxSetTimer = false;
  785. }
  786. }
  787. CWnd::OnTimer(nIDEvent);
  788. }
  789. void CToolTipEx::OnNcPaint()
  790. {
  791. m_DittoWindow.DoNcPaint(this);
  792. }
  793. void CToolTipEx::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
  794. {
  795. CWnd::OnNcCalcSize(bCalcValidRects, lpncsp);
  796. m_DittoWindow.DoNcCalcSize(bCalcValidRects, lpncsp);
  797. }
  798. HITTEST_RET CToolTipEx::OnNcHitTest(CPoint point)
  799. {
  800. UINT Ret = m_DittoWindow.DoNcHitTest(this, point);
  801. if(Ret == -1)
  802. return CWnd::OnNcHitTest(point);
  803. return Ret;
  804. }
  805. void CToolTipEx::OnNcLButtonDown(UINT nHitTest, CPoint point)
  806. {
  807. int buttonPressed = m_DittoWindow.DoNcLButtonDown(this, nHitTest, point);
  808. if (buttonPressed != 0)
  809. {
  810. SetTimer(TIMER_BUTTON_UP, 100, NULL);
  811. }
  812. CWnd::OnNcLButtonDown(nHitTest, point);
  813. }
  814. void CToolTipEx::OnNcLButtonUp(UINT nHitTest, CPoint point)
  815. {
  816. long lRet = m_DittoWindow.DoNcLButtonUp(this, nHitTest, point);
  817. switch(lRet)
  818. {
  819. case BUTTON_CLOSE:
  820. Hide();
  821. break;
  822. case BUTTON_CHEVRON:
  823. m_DittoWindow.MinMaxWindow(this, SWAP_MIN_MAX);
  824. OnNcPaint();
  825. break;
  826. }
  827. KillTimer(TIMER_BUTTON_UP);
  828. CWnd::OnNcLButtonUp(nHitTest, point);
  829. }
  830. void CToolTipEx::OnNcMouseMove(UINT nHitTest, CPoint point)
  831. {
  832. m_DittoWindow.DoNcMouseMove(this, nHitTest, point);
  833. if ((m_bMaxSetTimer == false) && m_DittoWindow.m_bMinimized)
  834. {
  835. COleDateTimeSpan sp = COleDateTime::GetCurrentTime() - m_DittoWindow.m_TimeMinimized;
  836. if (sp.GetTotalSeconds() >= m_lDelayMaxSeconds)
  837. {
  838. SetTimer(TIMER_AUTO_MAX, CGetSetOptions::GetTimeBeforeExpandWindow(), NULL);
  839. m_bMaxSetTimer = true;
  840. }
  841. }
  842. CWnd::OnNcMouseMove(nHitTest, point);
  843. }
  844. void CToolTipEx::OnOptions()
  845. {
  846. POINT pp;
  847. CMenu cmPopUp;
  848. CMenu *cmSubMenu = NULL;
  849. GetCursorPos(&pp);
  850. if(cmPopUp.LoadMenu(IDR_DESC_OPTIONS_MENU) != 0)
  851. {
  852. cmSubMenu = cmPopUp.GetSubMenu(0);
  853. if(!cmSubMenu)
  854. {
  855. return ;
  856. }
  857. GetCursorPos(&pp);
  858. //theApp.m_Language.UpdateRightClickMenu(cmSubMenu);
  859. if(CGetSetOptions::GetRememberDescPos())
  860. cmSubMenu->CheckMenuItem(ID_FIRST_REMEMBERWINDOWPOSITION, MF_CHECKED);
  861. if(CGetSetOptions::GetSizeDescWindowToContent())
  862. cmSubMenu->CheckMenuItem(ID_FIRST_SIZEWINDOWTOCONTENT, MF_CHECKED);
  863. if(CGetSetOptions::GetScaleImagesToDescWindow())
  864. cmSubMenu->CheckMenuItem(ID_FIRST_SCALEIMAGESTOFITWINDOW, MF_CHECKED);
  865. if (CGetSetOptions::GetMouseClickHidesDescription())
  866. cmSubMenu->CheckMenuItem(ID_FIRST_HIDEDESCRIPTIONWINDOWONM, MF_CHECKED);
  867. if (CGetSetOptions::GetWrapDescriptionText())
  868. cmSubMenu->CheckMenuItem(ID_FIRST_WRAPTEXT, MF_CHECKED);
  869. if (m_showPersistant)
  870. cmSubMenu->CheckMenuItem(ID_FIRST_ALWAYSONTOP, MF_CHECKED);
  871. UpdateMenuShortCut(cmSubMenu, ID_FIRST_WRAPTEXT, ActionEnums::TOGGLE_DESCRIPTION_WORD_WRAP);
  872. UpdateMenuShortCut(cmSubMenu, ID_FIRST_ALWAYSONTOP, ActionEnums::TOGGLESHOWPERSISTANT);
  873. cmSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, pp.x, pp.y, this, NULL);
  874. }
  875. }
  876. void CToolTipEx::UpdateMenuShortCut(CMenu *subMenu, int id, DWORD action)
  877. {
  878. if (m_pToolTipActions != NULL)
  879. {
  880. CString cs;
  881. subMenu->GetMenuString(id, cs, MF_BYCOMMAND);
  882. CString shortcutText = m_pToolTipActions->GetCmdKeyText(action);
  883. if (shortcutText != _T("") &&
  884. cs.Find("\t" + shortcutText) < 0)
  885. {
  886. cs += "\t";
  887. cs += shortcutText;
  888. subMenu->ModifyMenu(id, MF_BYCOMMAND, id, cs);
  889. }
  890. }
  891. }
  892. void CToolTipEx::OnRememberwindowposition()
  893. {
  894. CGetSetOptions::SetRememberDescPos(!CGetSetOptions::GetRememberDescPos());
  895. }
  896. void CToolTipEx::OnSizewindowtocontent()
  897. {
  898. CGetSetOptions::SetSizeDescWindowToContent(!CGetSetOptions::GetSizeDescWindowToContent());
  899. CRect rect;
  900. this->GetWindowRect(&rect);
  901. Show(rect.TopLeft());
  902. }
  903. void CToolTipEx::OnScaleimagestofitwindow()
  904. {
  905. CGetSetOptions::SetScaleImagesToDescWindow(!CGetSetOptions::GetScaleImagesToDescWindow());
  906. m_imageViewer.UpdateBitmapSize();
  907. Invalidate();
  908. }
  909. void CToolTipEx::OnRButtonDown(UINT nFlags, CPoint point)
  910. {
  911. OnOptions();
  912. CWnd::OnRButtonDown(nFlags, point);
  913. }
  914. void CToolTipEx::OnSetFocus(CWnd* pOldWnd)
  915. {
  916. CWnd::OnSetFocus(pOldWnd);
  917. m_RichEdit.SetFocus();
  918. }
  919. void CToolTipEx::OnPaint()
  920. {
  921. CPaintDC dc(this); // device context for painting
  922. CRect rect;
  923. GetClientRect(rect);
  924. CBrush Brush, *pOldBrush;
  925. Brush.CreateSolidBrush(g_Opt.m_Theme.DescriptionWindowBG());
  926. pOldBrush = dc.SelectObject(&Brush);
  927. dc.FillRect(&rect, &Brush);
  928. // Cleanup
  929. dc.SelectObject(pOldBrush);
  930. }
  931. void CToolTipEx::OnFirstHidedescriptionwindowonm()
  932. {
  933. CGetSetOptions::SetMouseClickHidesDescription(!CGetSetOptions::GetMouseClickHidesDescription());
  934. }
  935. bool CToolTipEx::ToggleWordWrap()
  936. {
  937. bool didWordWrap = false;
  938. if (m_RichEdit.IsWindowVisible())
  939. {
  940. OnFirstWraptext();
  941. didWordWrap = true;
  942. }
  943. return didWordWrap;
  944. }
  945. void CToolTipEx::OnFirstWraptext()
  946. {
  947. CGetSetOptions::SetWrapDescriptionText(!CGetSetOptions::GetWrapDescriptionText());
  948. ApplyWordWrap();
  949. }
  950. void CToolTipEx::ApplyWordWrap()
  951. {
  952. if (CGetSetOptions::GetWrapDescriptionText())
  953. {
  954. m_RichEdit.SetTargetDevice(NULL, 0);
  955. }
  956. else
  957. {
  958. m_RichEdit.SetTargetDevice(NULL, 1);
  959. }
  960. }
  961. void CToolTipEx::HideWindowInXMilliSeconds(long lms)
  962. {
  963. SetTimer(HIDE_WINDOW_TIMER, lms, NULL);
  964. }
  965. void CToolTipEx::OnWindowPosChanging(WINDOWPOS* lpwndpos)
  966. {
  967. CWnd::OnWindowPosChanging(lpwndpos);
  968. //m_DittoWindow.SnapToEdge(this, lpwndpos);
  969. }
  970. void CToolTipEx::OnFirstAlwaysontop()
  971. {
  972. m_showPersistant = !m_showPersistant;
  973. if (m_showPersistant)
  974. {
  975. m_DittoWindow.m_customWindowTitle = _T("[Always on top]");
  976. m_DittoWindow.m_useCustomWindowTitle = true;
  977. ::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE);
  978. }
  979. else
  980. {
  981. m_DittoWindow.m_customWindowTitle = _T("");
  982. m_DittoWindow.m_useCustomWindowTitle = true;
  983. }
  984. ::SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_DRAWFRAME | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
  985. }
  986. BOOL CToolTipEx::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  987. {
  988. CString cs;
  989. cs.Format(_T("On Notify: %d\r\n"), ((LPNMHDR)lParam)->code);
  990. OutputDebugString(cs);
  991. switch (((LPNMHDR)lParam)->code)
  992. {
  993. case EN_LINK:
  994. {
  995. ENLINK *enLinkInfo = (ENLINK *)lParam; // pointer to a ENLINK structure
  996. if (enLinkInfo->msg == WM_LBUTTONUP)
  997. {
  998. CString s;
  999. m_RichEdit.GetTextRange(enLinkInfo->chrg.cpMin, enLinkInfo->chrg.cpMax, s);
  1000. if (s == m_mouseDownOnLink)
  1001. {
  1002. CHyperLink::GotoURL(s, SW_SHOW);
  1003. }
  1004. m_mouseDownOnLink = _T("");
  1005. }
  1006. if (enLinkInfo->msg == WM_LBUTTONDOWN)
  1007. {
  1008. m_RichEdit.GetTextRange(enLinkInfo->chrg.cpMin, enLinkInfo->chrg.cpMax, m_mouseDownOnLink);
  1009. }
  1010. }
  1011. break;
  1012. case SimpleBrowser::NotificationType::BeforeNavigate2:
  1013. {
  1014. SimpleBrowser::Notification * not = (SimpleBrowser::Notification *)lParam;
  1015. if (not != NULL)
  1016. {
  1017. if (not->URL.Find(_T("http")) >= 0)
  1018. {
  1019. CHyperLink::GotoURL(not->URL, SW_SHOW);
  1020. *pResult = TRUE;
  1021. //return TRUE;
  1022. }
  1023. }
  1024. }
  1025. break;
  1026. case 5:
  1027. int x = 0;
  1028. break;
  1029. }
  1030. return CWnd::OnNotify(wParam, lParam, pResult);
  1031. }
  1032. void CToolTipEx::OnEnMsgfilterRichedit21(NMHDR *pNMHDR, LRESULT *pResult)
  1033. {
  1034. MSGFILTER *pMsgFilter = reinterpret_cast<MSGFILTER *>(pNMHDR);
  1035. if (pMsgFilter != NULL)
  1036. {
  1037. switch (pMsgFilter->msg)
  1038. {
  1039. //handle click on the rich text control when it doesn't have focus
  1040. //set focus so the first click is handled by the rich text control
  1041. case WM_MOUSEACTIVATE:
  1042. m_RichEdit.SetFocus();
  1043. break;
  1044. case WM_MOUSEHWHEEL:
  1045. int delta = GET_WHEEL_DELTA_WPARAM(pMsgFilter->wParam);
  1046. if (delta < 0)
  1047. {
  1048. m_RichEdit.SendMessage(WM_HSCROLL, SB_LINERIGHT, NULL);
  1049. }
  1050. else
  1051. {
  1052. m_RichEdit.SendMessage(WM_HSCROLL, SB_LINELEFT, NULL);
  1053. }
  1054. break;
  1055. }
  1056. }
  1057. *pResult = 0;
  1058. }
  1059. LRESULT CToolTipEx::OnDpiChanged(WPARAM wParam, LPARAM lParam)
  1060. {
  1061. int dpi = HIWORD(wParam);
  1062. m_DittoWindow.OnDpiChanged(this, dpi);
  1063. RECT* const prcNewWindow = (RECT*)lParam;
  1064. SetWindowPos(NULL,
  1065. prcNewWindow->left,
  1066. prcNewWindow->top,
  1067. prcNewWindow->right - prcNewWindow->left,
  1068. prcNewWindow->bottom - prcNewWindow->top,
  1069. SWP_NOZORDER | SWP_NOACTIVATE);
  1070. m_optionsButton.Reset();
  1071. 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"));
  1072. m_clipDataFont.Detach();
  1073. 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"));
  1074. m_clipDataStatic.SetFont(&m_clipDataFont);
  1075. m_clipDataStatic.SetBkColor(g_Opt.m_Theme.DescriptionWindowBG());
  1076. m_clipDataStatic.SetTextColor(RGB(80, 80, 80));
  1077. m_folderPathStatic.SetFont(&m_clipDataFont);
  1078. m_folderPathStatic.SetBkColor(g_Opt.m_Theme.DescriptionWindowBG());
  1079. m_folderPathStatic.SetTextColor(RGB(80, 80, 80));
  1080. LOGFONT lf;
  1081. m_Font.GetLogFont(&lf);
  1082. lf.lfHeight = m_DittoWindow.m_dpi.Scale(m_fontHeight);
  1083. // Create the actual font object
  1084. m_Font.DeleteObject();
  1085. m_Font.CreateFontIndirect(&lf);
  1086. m_RichEdit.SetFont(&m_Font);
  1087. this->MoveControls();
  1088. this->Invalidate();
  1089. this->UpdateWindow();
  1090. return TRUE;
  1091. }
  1092. void CToolTipEx::OnMoving(UINT fwSide, LPRECT pRect)
  1093. {
  1094. CWnd::OnMoving(fwSide, pRect);
  1095. m_snap.OnSnapMoving(m_hWnd, pRect);
  1096. // TODO: Add your message handler code here
  1097. }
  1098. void CToolTipEx::OnEnterSizeMove()
  1099. {
  1100. m_snap.OnSnapEnterSizeMove(m_hWnd);
  1101. CWnd::OnEnterSizeMove();
  1102. }
  1103. void CToolTipEx::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  1104. {
  1105. int x = 9;
  1106. //m_scrollHelper.OnHScroll(nSBCode, nPos, pScrollBar);
  1107. }