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

Method ComboBoxSubclassProc

src/Utils/Theme.cpp:464–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464LRESULT CTheme::ComboBoxSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR /*uIdSubclass*/, DWORD_PTR dwRefData)
465{
466 switch (uMsg)
467 {
468 case WM_CTLCOLORDLG:
469 case WM_CTLCOLORSTATIC:
470 case WM_CTLCOLOREDIT:
471 case WM_CTLCOLORLISTBOX:
472 case WM_CTLCOLORBTN:
473 case WM_CTLCOLORSCROLLBAR:
474 {
475 auto hbrBkgnd = reinterpret_cast<HBRUSH*>(dwRefData);
476 HDC hdc = reinterpret_cast<HDC>(wParam);
477 SetTextColor(hdc, darkTextColor);
478 SetBkColor(hdc, darkBkColor);
479 if (!*hbrBkgnd)
480 *hbrBkgnd = CreateSolidBrush(darkBkColor);
481 return reinterpret_cast<LRESULT>(*hbrBkgnd);
482 }
483 case WM_DRAWITEM:
484 {
485 auto pDIS = reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);
486 HDC hDC = pDIS->hDC;
487 RECT rc = pDIS->rcItem;
488 wchar_t itemText[1024] = { 0 };
489
490 COMBOBOXEXITEM cbi = { 0 };
491 cbi.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY | CBEIF_INDENT;
492 cbi.iItem = pDIS->itemID;
493 cbi.cchTextMax = _countof(itemText);
494 cbi.pszText = itemText;
495
496 auto cwnd = GetParent(hWnd);
497 if (SendMessage(cwnd, CBEM_GETITEM, 0, reinterpret_cast<LPARAM>(&cbi)))
498 {
499 rc.left += (cbi.iIndent * 10);
500 auto img = (pDIS->itemState & LVIS_SELECTED) ? cbi.iSelectedImage : cbi.iImage;
501 if (pDIS->itemState & LVIS_FOCUSED)
502 ::SetBkColor(hDC, darkDisabledTextColor);
503 else
504 ::SetBkColor(hDC, darkBkColor);
505 ::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &rc, nullptr, 0, nullptr);
506
507 if (img)
508 {
509 auto imglist = reinterpret_cast<HIMAGELIST>(SendMessage(cwnd, CBEM_GETIMAGELIST, 0, 0));
510 if (imglist)
511 {
512 int iconX(0), iconY(0);
513 ImageList_GetIconSize(imglist, &iconX, &iconY);
514 ImageList_Draw(imglist, img, hDC, rc.left, rc.top, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(cbi.iOverlay));
515 rc.left += (iconX + 2);
516 }
517 }
518
519 SetTextColor(pDIS->hDC, darkTextColor);
520 SetBkMode(hDC, TRANSPARENT);
521 DrawText(hDC, cbi.pszText, -1, &rc, DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS);

Callers

nothing calls this directly

Calls 1

DrawTextFunction · 0.85

Tested by

no test coverage detected