MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / OnLButtonDown

Method OnLButtonDown

DebugView++/LogView.cpp:429–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429void CLogView::OnLButtonDown(UINT flags, CPoint point)
430{
431 if ((flags & MK_SHIFT) == 0 || m_highlightText.empty())
432 {
433 SetMsgHandled(false);
434 return;
435 }
436
437 LVHITTESTINFO info;
438 info.flags = 0;
439 info.pt = point;
440 SubItemHitTest(&info);
441 if ((info.flags & LVHT_ONITEM) == 0 || info.iSubItem != ColumnToSubItem(Column::Message))
442 {
443 SetMsgHandled(false);
444 return;
445 }
446
447 CClientDC dc(*this);
448 Win32::GdiObjectSelection font(dc, GetFont());
449
450 int x0 = GetSubItemRect(info.iItem, info.iSubItem, LVIR_BOUNDS).left + GetHeader().GetBitmapMargin();
451 auto line = TabsToSpaces(GetItemWText(info.iItem, ColumnToSubItem(Column::Message)));
452 auto pos = 0;
453 int min = 1000 * 1000;
454 bool found = false;
455 for (;;)
456 {
457 pos = line.find(m_highlightText, pos);
458 if (pos == line.npos)
459 break;
460
461 int x1 = x0 + GetTextSize(dc.m_hDC, line, pos).cx;
462 int x2 = x0 + GetTextSize(dc.m_hDC, line, pos + m_highlightText.size()).cx;
463 if (std::abs(point.x - x1) < min)
464 {
465 min = std::abs(point.x - x1);
466 m_dragStart = CPoint(x2, point.y);
467 }
468 if (std::abs(point.x - x2) < min)
469 {
470 min = std::abs(point.x - x2);
471 m_dragStart = CPoint(x1, point.y);
472 }
473
474 pos += m_highlightText.size();
475 found = true;
476 }
477 if (!found)
478 {
479 SetMsgHandled(false);
480 return;
481 }
482
483 StopTracking();
484
485 SetCapture();
486 m_dragging = true;

Callers

nothing calls this directly

Calls 3

TabsToSpacesFunction · 0.85
GetTextSizeFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected