Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Property Grid
  New Posts New Posts RSS Feed - Highlight Selected Report Columns
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Highlight Selected Report Columns

 Post Reply Post Reply
Author
Message
eam74 View Drop Down
Groupie
Groupie
Avatar

Joined: 18 June 2014
Location: USA
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote eam74 Quote  Post ReplyReply Direct Link To This Post Topic: Highlight Selected Report Columns
    Posted: 18 June 2014 at 11:30am
Hi all,

I am working on a report control for my application and have a couple features that I haven't been able to find a solution for yet:

1. When a user clicks on an item, highlight the corresponding column.  If you sort, the column will be highlighted, but in my control the sort must be disabled, so there is no highlight.

2. Allow the user to select multiple columns.  I know this is possible because the report sample allows this, but I can't figure out where this option is set, unless this also is a consequence of disabling sorting.

3. (would be nice, but not critical) Remove the selection box around the row and customize the background color.  I am able to turn off highlighting for the row with wndReport.SelectionEnable(FALSE) but the box still shows up.  I found an old forum topic which suggests the function to override is GetItemMetrics, which I did, but it's not getting called - where exactly should this be added?

TIA
Xtreme ToolkitPro (C++) v16.1.0, Windows 7
Back to Top
eam74 View Drop Down
Groupie
Groupie
Avatar

Joined: 18 June 2014
Location: USA
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote eam74 Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2014 at 2:26pm
Updates!

1. Based on the MessageRecord class in ReportSample, I created a custom record class which overrides GetItemMetrics.  This works to alter the colors of the currently selected row, but no others.  It appears to be calling this function for all rows so I don't know why it only changes colors for the selected row.

Code:

void CCustomRecord::GetItemMetrics(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pItemMetrics) {
    if (pDrawArgs->pColumn->GetIndex() == 3) { // hard-coded temporarily
        pDrawArgs->pControl->GetPaintManager()->m_clrHighlight = RGB(140, 240, 255);
        pDrawArgs->pControl->GetPaintManager()->m_clrHighlightText = RGB(0,0,0);
    } else if (pDrawArgs->pRow->IsSelected()) {
        pDrawArgs->pControl->GetPaintManager()->m_clrHighlight = RGB(240, 140, 255);
        pDrawArgs->pControl->GetPaintManager()->m_clrHighlightText = RGB(0,0,0);
    }
}

3. reportCtrl.ShowRowFocus(FALSE);
Xtreme ToolkitPro (C++) v16.1.0, Windows 7
Back to Top
eam74 View Drop Down
Groupie
Groupie
Avatar

Joined: 18 June 2014
Location: USA
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote eam74 Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2014 at 3:11pm
Further update on item #1:

Able to paint a particular column using a custom CXTPReportPaintManager that overrides DrawColumnBackground, as such:

void CCustomReportPaintManager::DrawColumnBackground(CDC* pDC, CXTPReportColumn* pColumn, CRect rcColumn, BOOL& bColumnPressed, BOOL& bDraggingFromHeader, CXTPReportHeader* pHeader) {
    if (pColumn->GetIndex()==1){ // column
        CXTPReportRecords* rows = pColumn->GetControl()->GetRecords();
        int i;
        for (i=0; i < rows->GetCount(); i++) {
            CXTPReportRecord* r = pColumn->GetControl()->GetRecords()->GetAt(i);
            r->GetItem(pColumn)->SetBackgroundColor(RGB(140, 240, 255));
        }
        pColumn->SetAlignment(xtpColumnTextRight);
    } else {
        pColumn->SetAlignment(xtpColumnTextCenter);
    }
}


Still some work left in tracking which is the currently selected column, and haven't found anything for item #2, but hopefully this is of use to someone searching in the future :)
Xtreme ToolkitPro (C++) v16.1.0, Windows 7
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.141 seconds.