Custom color for row selection

Advertisement

WaldemarH
Joined:
Posts:
1

Custom color for row selection

Hi guys.

First thank you for the awesome program.

Second can you give us the option to change the row selection color (font and background).
As if you use dark mode the selection is hardly visible on a low brightness screen.
If you look very, very closely you will see that there are two rows selected on the right screen.

Anyway it's a real pain and any help is welcomed.

Best regards
Waldemar

20220518_153748.jpg

Reply with quote

Advertisement

Guest

Re: Custom color for row selection.

Hi Martin.

Thanks for the info. I assume you are using List view. There was a discussion on this.. code below:
Selection Color in ListView win32API (C++)

Now I'm also thinking to change the colors globally, but I need to figure it out how these theming stuff works.

Anyway have seen that WinSCP is on GitHub... do you need whole Embarcadero C++ Builder XE6 Professional to build it or would some free option of theirs do the work also?
I would be glad to write this on my own but have no wish to pay another 500eur for another IDE when I already own VS2022.

BrW

case CDDS_ITEMPREPAINT:
    if (ListView_GetItemState(hListView,lplvcd->nmcd.dwItemSpec,LVIS_FOCUSED|LVIS_SELECTED) == (LVIS_FOCUSED|LVIS_SELECTED))
    {
        RECT textRect;
        wchar_t iSubTxt1[64];
        wchar_t iSubTxt2[64];
        HFONT oldFont, newFont;
 
        ListView_GetItemRect(hListView,lplvcd->nmcd.dwItemSpec,&ItemRect,LVIR_BOUNDS);
        bgRgn = CreateRectRgnIndirect(&ItemRect);
        MyBrush = CreateSolidBrush(RGB(100,100,100));
        FillRgn(lplvcd->nmcd.hdc, bgRgn, MyBrush);
        DeleteObject(MyBrush);
 
        SetTextColor(lplvcd->nmcd.hdc, RGB(255,255,255));
 
        newFont = CreateFont(16, 0, 0, 0, FW_NORMAL, TRUE, FALSE, FALSE,
                                EASTEUROPE_CHARSET, 0, 0, CLEARTYPE_NATURAL_QUALITY,
                                DEFAULT_PITCH | FF_DONTCARE, L"Times New Roman");
        oldFont = (HFONT)SelectObject(lplvcd->nmcd.hdc,newFont);
 
        ListView_GetItemText(hListView,lplvcd->nmcd.dwItemSpec,0,iSubTxt1,64);
        SetRect(&textRect, ItemRect.left+5,ItemRect.top, ItemRect.right, ItemRect.bottom);
        DrawText(lplvcd->nmcd.hdc,iSubTxt1,-1,&textRect, DT_LEFT | DT_NOCLIP);
        ListView_GetItemText(hListView,lplvcd->nmcd.dwItemSpec,1,iSubTxt2,64);
        SetRect(&textRect, ItemRect.left+Width/3+5,ItemRect.top, ItemRect.right, ItemRect.bottom);
        DrawText(lplvcd->nmcd.hdc,iSubTxt2,-1,&textRect, DT_LEFT | DT_NOCLIP);
 
        SelectObject(lplvcd->nmcd.hdc,oldFont);
        DeleteObject(newFont);
 
        return CDRF_SKIPDEFAULT;
    }

Reply with quote

Advertisement

You can post new topics in this forum