MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / ButtonSubclassProc

Method ButtonSubclassProc

src/Utils/Theme.cpp:603–937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601#endif
602
603LRESULT CTheme::ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR /*uIdSubclass*/, DWORD_PTR /*dwRefData*/)
604{
605 switch (uMsg)
606 {
607 case WM_SETTEXT:
608 case WM_ENABLE:
609 case WM_STYLECHANGED:
610 {
611 LRESULT res = DefSubclassProc(hWnd, uMsg, wParam, lParam);
612 InvalidateRgn(hWnd, nullptr, FALSE);
613 return res;
614 }
615 case WM_PAINT:
616 {
617 PAINTSTRUCT ps;
618 HDC hdc = BeginPaint(hWnd, &ps);
619 if (hdc)
620 {
621 LONG_PTR dwStyle = GetWindowLongPtr(hWnd, GWL_STYLE);
622 LONG_PTR dwButtonStyle = LOWORD(dwStyle);
623 LONG_PTR dwButtonType = dwButtonStyle & 0xF;
624 RECT rcClient;
625 GetClientRect(hWnd, &rcClient);
626
627 if ((dwButtonType & BS_GROUPBOX) == BS_GROUPBOX)
628 {
629 if (CAutoThemeData hTheme = OpenThemeData(hWnd, L"Button"))
630 {
631 BP_PAINTPARAMS params = { sizeof(BP_PAINTPARAMS) };
632 params.dwFlags = BPPF_ERASE;
633
634 RECT rcExclusion = rcClient;
635 params.prcExclude = &rcExclusion;
636
637 // We have to calculate the exclusion rect and therefore
638 // calculate the font height. We select the control's font
639 // into the DC and fake a drawing operation:
640 auto hFontOld = reinterpret_cast<HFONT>(SendMessage(hWnd, WM_GETFONT, 0L, 0));
641 if (hFontOld)
642 hFontOld = static_cast<HFONT>(SelectObject(hdc, hFontOld));
643
644 RECT rcDraw = rcClient;
645 DWORD dwFlags = DT_SINGLELINE;
646
647 // we use uppercase A to determine the height of text, so we
648 // can draw the upper line of the groupbox:
649 DrawTextW(hdc, L"A", -1, &rcDraw, dwFlags | DT_CALCRECT);
650
651 if (hFontOld)
652 {
653 SelectObject(hdc, hFontOld);
654 hFontOld = nullptr;
655 }
656
657 rcExclusion.left += 2;
658 rcExclusion.top += RECTHEIGHT(rcDraw);
659 rcExclusion.right -= 2;
660 rcExclusion.bottom -= 2;

Callers

nothing calls this directly

Calls 12

GetClientRectFunction · 0.85
DetermineGlowSizeFunction · 0.85
GetEditBorderColorFunction · 0.85
GetRoundRectPathFunction · 0.85
DrawTextFunction · 0.85
GetStateFromBtnStateFunction · 0.85
DrawFocusRectFunction · 0.85
PaintControlFunction · 0.85
DrawPathMethod · 0.80
GetDPIXMethod · 0.80
getMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected