Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Selected record background color
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Selected record background color

 Post Reply Post Reply
Author
Message
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Topic: Selected record background color
    Posted: 10 January 2018 at 8:29pm
Hi,

One of the column is state which has background color (red, orange, yellow, green).

When the record selected the select color overlay the state column color.

I need a way to retain the background color of the state column when the record selected.

I need a quick response.

Thanks,

yoavm


Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2018 at 4:06am
Hello yoavm,

Try to delete last part of CXTPReportRow::GetItemMetrics() method (Source\ReportControl\XTPReportRow.cpp)

void CXTPReportRow::GetItemMetrics(
    XTP_REPORTRECORDITEM_DRAWARGS *pDrawArgs,
    XTP_REPORTRECORDITEM_METRICS  *pItemMetrics)
{
    ASSERT(m_pRecord);
........
        }
    }
    
    if (isSelected
        && (pDrawArgs->pDC
        && !pDrawArgs->pDC->IsPrinting())
        && !pDrawArgs->pControl->IsIconView())
    {
        if (pDrawArgs->pColumn
            && isFocused
            && m_pControl->m_pFocusedColumn == pDrawArgs->pColumn)
            return;

        if (hasFocus)
        {
            pItemMetrics->clrForeground = (lf.lfWeight == FW_BOLD && !pPaintManager->m_clrBoldTextHighlight.IsDefaultValue() 
                ? pPaintManager->m_clrBoldTextHighlight 
                : pPaintManager->m_clrHighlightText);
            pItemMetrics->clrBackground = pPaintManager->m_clrHighlight;
        }
        else if (!pPaintManager->m_bHideSelection)
        {
            pItemMetrics->clrForeground = pPaintManager->m_clrSelectedRowText;
            pItemMetrics->clrBackground = pPaintManager->m_clrSelectedRow;
        }
    }
}


Regards,
 Oleksandr Lebed
Back to Top
yoavm View Drop Down
Groupie
Groupie


Joined: 15 July 2006
Status: Offline
Points: 47
Post Options Post Options   Thanks (0) Thanks(0)   Quote yoavm Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2018 at 11:06am

This will remove the selected color and leave the selected line without color.

This was not what I need.

I need the selected color with the ability to override background color for a specific column.

Thanks,

yoavm


Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2018 at 11:23am
you can play with virtual method  CXTPReportRecord::GetItemMetrics()  and that method CXTPReportRow::GetItemMetrics() from library.

see our sample 
Samples\ReportControl\ReportSample\TaskListView.cpp   method CTaskRecord::GetItemMetrics()  (you can see this sample with by clicking in main menu "Report Control" > "Control Test" > "Task List sample")

such virtual methods are called from CXTPReportRow::GetItemMetrics() 
void CXTPReportRow::GetItemMetrics(
    XTP_REPORTRECORDITEM_DRAWARGS *pDrawArgs,
    XTP_REPORTRECORDITEM_METRICS  *pItemMetrics)
{
    ASSERT(m_pRecord);
    ASSERT(pDrawArgs->pRow  == this);
    ASSERT(pDrawArgs->pItem != NULL);

    if (!m_pRecord || !pDrawArgs->pItem)
        return;

    CXTPReportPaintManager *pPaintManager = pDrawArgs->pControl->GetPaintManager();

    pItemMetrics->pFont            = &pPaintManager->m_xtpFontText;
    pItemMetrics->clrForeground    = pPaintManager->m_clrWindowText;
    pItemMetrics->clrBackground    = XTP_REPORT_COLOR_DEFAULT;
    pItemMetrics->nColumnAlignment = pDrawArgs->nTextAlign;
    pItemMetrics->nItemIcon        = XTP_REPORT_NOICON;

    m_pRecord->GetItemMetrics(pDrawArgs, pItemMetrics);
    pDrawArgs->pItem->GetItemMetrics(pDrawArgs, pItemMetrics);

    LOGFONT lf;
    pItemMetrics->pFont->GetLogFont(&lf);
    if (lf.lfWeight == FW_BOLD && !pPaintManager->m_clrBoldText.IsDefaultValue())
    {
        pItemMetrics->clrForeground = pPaintManager->m_clrBoldText;
    }

    m_pControl->GetItemMetrics(pDrawArgs, pItemMetrics);
    pDrawArgs->nTextAlign = pItemMetrics->nColumnAlignment;

.....
}
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.139 seconds.