MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / EditWndProc

Method EditWndProc

src/windows/MessageEditor.cpp:555–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555LRESULT MessageEditor::EditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
556{
557 MessageEditor* pThis = (MessageEditor*) GetWindowLongPtr(GetParent(hWnd), GWLP_USERDATA);
558 assert(pThis);
559
560 switch (uMsg)
561 {
562 case WM_DESTROY:
563 {
564 SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) m_editWndProc);
565 pThis->m_edit_hwnd = NULL;
566 break;
567 }
568 case WM_KEYUP:
569 case WM_KEYDOWN:
570 {
571 if (pThis->m_autoComplete.HandleKeyMessage(uMsg, wParam, lParam))
572 return 0;
573
574 if (wParam == VK_SHIFT)
575 m_shiftHeld = uMsg == WM_KEYDOWN;
576
577 break;
578 }
579 case WM_UPDATETEXTSIZE:
580 {
581 RECT rect{};
582 GetClientRect(g_Hwnd, &rect);
583 int maxHeight = (rect.bottom - rect.top) / 3;
584
585 // Now check for expansion.
586 // TODO: Figure out why I had to lower the line height by 1 pixel to make the cursor not deviate 1px up
587 int lineCount = Edit_GetLineCount(hWnd);
588 int expandByTarget = (lineCount - 1) * (pThis->m_lineHeight - 1);
589 if (pThis->m_bReplying)
590 expandByTarget += pThis->m_mentionAreaHeight;
591 if (pThis->m_bEditing)
592 expandByTarget += pThis->m_mentionAreaHeight;
593 expandByTarget = std::min(expandByTarget, maxHeight);
594
595 if (pThis->m_bBrowsingPast)
596 expandByTarget += pThis->m_jumpPresentHeight;
597
598 pThis->Expand(expandByTarget - pThis->m_expandedBy);
599 break;
600 }
601 case WM_PASTE:
602 case WM_CUT:
603 case WM_COPY:
604 case WM_SETTEXT:
605 {
606 LRESULT lres = CallWindowProc(m_editWndProc, hWnd, uMsg, wParam, lParam);
607 pThis->OnUpdateText();
608 return lres;
609 }
610 case WM_CHAR:
611 {
612 if (pThis->m_autoComplete.HandleCharMessage(uMsg, wParam, lParam))

Callers

nothing calls this directly

Calls 9

GetDiscordInstanceFunction · 0.85
HandleKeyMessageMethod · 0.80
ExpandMethod · 0.80
OnUpdateTextMethod · 0.80
HandleCharMessageMethod · 0.80
HasPermissionMethod · 0.80
TryToSendMessageMethod · 0.80
TypingMethod · 0.80
GetCurrentChannelMethod · 0.45

Tested by

no test coverage detected