Click here to Skip to main content
15,881,882 members
Articles / Desktop Programming / MFC
Article

Report control - an Outlook 2000 style SuperGrid Report Control

Rate me:
Please Sign up or sign in to vote.
4.90/5 (44 votes)
14 Jun 2001 1.5M   8.7K   152   165
An Outlook 98/2000 Style SuperGrid Report Control that tries to overcome some of the weaknesses of other implementations.

Sample Image

Introduction

This ReportCtrl control is an Outlook 98/2000 style SuperGrid control. I've seen many implementations, most of them based on the standard CListCtrl. All implementations have their specific weaknesses. This implementation tries to overcome some of the weaknesses, although for some purposes it may introduce others.

The documentation is sparse, because I do not have much time to write documentation. However, the included demo is a great help in understanding how to use the features of the control and many features are demonstrated in a practical manner. The interfaces of the controls highly resemble the interfaces of similiar MFC controls, like the list control and header control. So, for the more experienced MFC coder, it should not be a big problem to understand how to use the control in their own projects...

Version History Excerpt (refer to source file for complete history)

This ReportCtrl control is an Outlook 98/2000 style SuperGrid control. I've seen many implementations, most of them based on the standard CListCtrl. All implementations have their specific weaknesses. This implementation tries to overcome some of the weaknesses, although for some purposes it may introduce others.

The documentation is sparse, because I do not have much time to write documentation. However, the included demo is a great help in understanding how to use the features of the control and many features are demonstrated in a practical manner. The interfaces of the controls highly resemble the interfaces of similiar MFC controls, like the list control and header control. So, for the more experienced MFC coder, it should not be a big problem to understand how to use the control in their own projects...

Version history excerpt (refer to source file for complete history):

2.0.1	- Fixed bug in DeleteItem for tree control mode.
	- Fixed item expansion for single subitem hierarchy items.
	- Added GetExpandedItemText to allow expanded items to show different
	  text from the subitem text.
	- Added support for radio button and disabled check marks and 
	  radio buttons.
	- Added RVP_ENABLEFLATCHECKMARK property, to control the visual style
	  of check marks or radio buttons.
	- Added support for check mark and radio button image list.
	- Changed CurrentFocus() to GetCurrentFocus().
	- Changed OnKillFocus to recognize all child windows.
	- Extended MeasureItem function.
	- Fixed GetNextItem() for RVTI_ROOT.
	- Added support for SetRedraw suggested by Phil J Pearson.
	- Optimized InsertItem performance by skipping GetRowFromItem
	  when the focus is not on an reorderable row, as suggested by
	  Phil J Pearson.
	- Added disabled background function to CReportSubItemListCtrl.
	- Added pre-create style passing to CReportView.
	- Adjusted edit box position.
	- Fixed a bug related to keydown messages in unfocused state.
	- Fixed tip redraw problem and tip background color mismatch.
	- Fixed kill tip on WM_KILLFOCUS, finally fixing click and double
	  click on expanded subitems.
	- Added GetSelectedItems method.
	- Fixed a selection bug in ClearSelection.
	- Made GetReportCtrlPtr virtual and changed CReportView to use
	  overriden function to get a pointer to the embedded CReportCtrl.
	  This allows control derived from CReportCtrl to be embedded in 
	  CReportView.
	- Added UpdateWindow to SetRedraw when re-enabling redrawing.
	- Removed legacy definitions from header file.
	- Added blended image support through state bits, focus and selection
	  through the RVP_ENABLEIMAGEBLENDING and RVP_BLENDCOLOR properties.
	- Added support for overlay images.
	- Added Win2K tip fading to CReportTipCtrl.
	- Fixed nFormat subitem member update in OnHdnItemChanged, as
	  suggested by Sven Ritter.
	- Added selective item cache flush to SetItemCount.
	- Added GetItemString() function to retrieve an item as a string.
	- Added clipboard Copy support and clipboard separator and indent
	  properties.
	- Fixed OnRvnEndItemEdit to not loose lParam, as suggested by
	  Paul Hurley.
	- Added GetSortSettings() to retrieve sorting settings.
	- Made SelectRows virtual to allow owner data multiple selection
	  management.
	- Fixed a bug in DeleteItem for trees.
	- Fixed various mouse button, keyboard selection/focus issues.
2.0.0	- Made scrolling with left or right cursor key dependent on
	  focus subitems style.
	- Fixed resource leak in empty list, as suggested by Florent
	  Odelain.
	- Fixed ResortItems and DeactivateSubItem bugs as suggested by
	  Rafael Lombardi Santos.
	- Fixed HitTest on reordered columns, reported by Trevor Ash.
	- Fixed item rect returned in hitinfo structure for scrolled
	  controls. This fixes incorrect positioning of tip windows.
	- Added CReportHeaderCtrl to access CFlatHeaderCtrl's protected
	  members.
	- Added first column indent functions, to support hierarchy
	  GUI elements.
	- Fixed HitTest to retrieve correct item data.
	- Added parameter to sort callback.
	- Removed SortAllSubItems, because implementation was not
	  maintained and buggy.
	- Fixed IsItemVisible and added GetTopIndex(), PageUp() and
	  PageDown() as suggested by Alina Kozlovsky.
	- Added tree control features, both in preparation of group
	  view mode as well as a standalone feature.
	- Fixed subitem text drawing following uninitialized subitems.
	- Changed CompareItems callback and functions to support
	  separate subitems to enable tree view and group view sorting.
	- Extended CompareItems to sort on checkboxes as suggested by
	  Peter Lagerhem.
	- Fixed offset of subitem tip for items with images or checks
	  and text and related hittesting issues.
	- Fixed NOHEADER style.
	- Changed selected items and tree boxes in tree view mode visuals
	  to match common control look and feel.
	- Fixed default height setting for font size updates with images.
	- Fixed cosmetic bug with RVS_SHOWHGRID style, as suggested by Matrix.
	- Fixed SelectAll() for empty control as suggested by Dmitry Sazonov.
	- Added GetStyle().
	- Added RVN_HEADERRCLICK to support popup menus on header.
	- Fixed tooltip double click and ALT key relay events by removing
	  mouse capture.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralProblem with Visual Studio.NET Pin
15-Apr-02 13:01
suss15-Apr-02 13:01 
GeneralRe: Problem with Visual Studio.NET Pin
18-Apr-02 10:17
suss18-Apr-02 10:17 
GeneralSupberb! Pin
NormDroid11-Apr-02 3:10
professionalNormDroid11-Apr-02 3:10 
GeneralRe: Supberb! Pin
Jon Sagara2-Jul-03 18:50
Jon Sagara2-Jul-03 18:50 
QuestionHow to do a custom sort? Pin
13-Mar-02 4:14
suss13-Mar-02 4:14 
AnswerRe: How to do a custom sort? Pin
Chris Hambleton14-Jan-03 3:30
Chris Hambleton14-Jan-03 3:30 
GeneralRe: How to do a custom sort? Pin
Jon Sagara13-Jun-03 11:02
Jon Sagara13-Jun-03 11:02 
GeneralRe: How to do a custom sort? Pin
Chris Hambleton13-Jun-03 12:39
Chris Hambleton13-Jun-03 12:39 
Sure -- the way I did it was to put them into the 'correct' order for the uniquely sorted items in the first place by an stl vector sort (MemVerseCompare). When the user clicks the headers, the items in that column obey the inital ordering, and aren't resorted, but they flip from ascending<-->descending order.

The problem with this approach is that it only orders them as they're loaded into the list -- if you add new items later, they aren't sorted. You'll probably have to use the sort callback that's part of the control itself, but I didn't have time to figure that out... Hmmm | :| Maybe ask the author to add some custom sort examples to his demo... Smile | :)



void CLookupForm::DisplayList()
{
// clear the list ctrl & set the starting id
m_lcResults.DeleteAllItems();
DWORD nListID = STARTING_ID;

// sort all the items in the vector
SortMemVerses(m_vLookupResults);

... /* then, add all the items from the vector into the list control, tying he lparam/data of each list item into the corresponding item in the vector*/
...
}

void CLookupForm::SortMemVerses(MemEntries &vMemEntries)
{
// sort the entire stl vector by the MemVerseCompare function
sort(vMemEntries.begin(), vMemEntries.end(), MemVerseCompare);
}


bool MemVerseCompare(const MemEntry& m1, const MemEntry& m2)
{
if(m1.vVerse.sBook != m2.vVerse.sBook)
return m1.vVerse.nBookIndex < m2.vVerse.nBookIndex ? 1 : 0;
else
{
if(m1.vVerse.nChapterNum != m2.vVerse.nChapterNum)
return m1.vVerse.nChapterNum < m2.vVerse.nChapterNum ? 1 : 0;
else
{
if(m1.vVerse.nVerseNum != m2.vVerse.nVerseNum)
return m1.vVerse.nVerseNum < m2.vVerse.nVerseNum ? 1 : 0;
else
return m1.vVerse.sVerseID < m2.vVerse.sVerseID ? 1 : 0;
}
}
}

<I>"No one goes to hell because of their sin, but because of rejecting God's method of salvation: His Son's life for yours..."<br><br>"It does not take a majority to prevail ... but rather an irate, tireless minority, keen on setting brushfires of freedom in the minds of men." --Samuel Adams</I>
GeneralRe: How to do a custom sort? Pin
Jon Sagara13-Jun-03 15:13
Jon Sagara13-Jun-03 15:13 
GeneralSome fixes for .NET Pin
Marcello4-Mar-02 14:25
Marcello4-Mar-02 14:25 
QuestionIs it possible to have different heights and font sizes for grid rows? Pin
15-Nov-01 10:57
suss15-Nov-01 10:57 
Generalcheckbox-questions Pin
29-Oct-01 20:28
suss29-Oct-01 20:28 
GeneralTree items Pin
18-Oct-01 17:08
suss18-Oct-01 17:08 
GeneralRe: Tree items Pin
CK Ng15-Mar-02 4:58
CK Ng15-Mar-02 4:58 
GeneralRe: Tree items Pin
Bui Huy Kien17-Nov-02 16:12
Bui Huy Kien17-Nov-02 16:12 
GeneralRe: Tree items Pin
Faarooq17-Dec-03 16:51
Faarooq17-Dec-03 16:51 
Generaldemo crashes Pin
26-Sep-01 12:59
suss26-Sep-01 12:59 
GeneralRe: demo crashes Pin
Jon Sagara16-May-03 10:52
Jon Sagara16-May-03 10:52 
GeneralOut of Memory on NT4 Pin
Giles18-Sep-01 4:45
Giles18-Sep-01 4:45 
GeneralBuggy tooltips... Pin
17-Sep-01 7:32
suss17-Sep-01 7:32 
GeneralResource Leak Pin
FilthyZombie16-Sep-01 22:54
FilthyZombie16-Sep-01 22:54 
GeneralRe: Resource Leak Pin
19-Sep-01 13:18
suss19-Sep-01 13:18 
GeneralRe: Resource Leak / Grid Painting Problems Pin
Andreas Saurwein7-Jan-02 4:52
Andreas Saurwein7-Jan-02 4:52 
GeneralCase insensitive FindItem() Pin
Paul Hurley15-Sep-01 13:37
Paul Hurley15-Sep-01 13:37 
GeneralEffort for more speed Pin
9-Sep-01 14:20
suss9-Sep-01 14:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.