Click here to Skip to main content
Click here to Skip to main content

SuperGrid - Yet Another listview control

By , 8 Dec 1999
 

Sample Image

Okay yet another full blown ownerdraw listview control with a tree like thing in the first column.

What´s new:

  • subitems now supports images
  • improved sorting
  • bugfixes reported by you.

please see the history section in the SuperGridCtrl.cpp file for further reading.

Features:

The listview control has support for editing subitems and basic user navigation. To edit an item hit the Enter key to start editing, when done editing, hit the Enter Key again. The listview control also has support for sorting items, drag and drop, basic scroll, autoscroll and autoexpand when dragging an item over another item. The listview control supports Insert/Delete items and you can use the +,-,* keys to expand/collapse items. The listview control does NOT support header drag/drop operations. Thanks for all them positive emails I have recived. If you have any suggestions to some future version let me know.

Note:

The class CSuperGridCtrl is derived from CListCtrl and it has a nested class called CTreeItem. The CTreeItem represents a node in a linked list. Each CTreeItem has a CObList representing its children and a few data members telling you the current status on the node e.g expanded, haschildren etc. Each listview item has a pointer to the CTreeItem(stored in the lParam of course). The CTreeItem has an associated class called CItemInfo. The CItemInfo class represents the data in the listview. This class is just a wrapper for the CStringArray, each item in the array represents a subitem. You may have to modify this class to suit your logical data-representation in the listview. In each CItemInfo you may associate a controltype: default controltype is an edit-control. In the source code you will find an example on how to associate a combobox control to a specific CItemInfo and how to initalize the combobox with default values.

Another standard control which is implicit in the listview control are the checkbox-control, by using the LVS_EX_CHECKBOXES style you will have this control for free, nothing new here....but in the CItemInfo class you will be able to test which items are checked. The class CMySuperGrid which is derived from CSuperGridCtrl shows you how to initalize the grid, insert root items, insert items, sort items, associate controltypes and how to implement 'print preview' selected or checked items depending on which extended style you have set, it also shows you have to search for items, select items, delete items and how to set the current listview icon and individual cell color. The source code shows you how to use the listview control in a CView derived class and in a CDialog derived class.

The listview control was built with Visual C++ 6.0 (sp10) level 8 on Windows 2000 beta 9, I don't remember the Netcard ID ;-).

In the SuperGridCtrl.h header file you will find further information/documentation on how to use this listview control. I have included a "history" section in the SuperGridCtrl.cpp file.

Drop me a line when you find that bug or if you have any comments / suggestions / improvement at all to this listview control.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Allan Nielsen
Switzerland Switzerland
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionocx file for use in VB6memberL B Choudhury28 Jan '13 - 19:06 
Can some one help me with an ocx file of this cute code so that the same can be used in VB6 for saving and retrieving data from .mdb file.
QuestionHow to real delete all, include column header? [modified]memberJason Tian19 Nov '11 - 19:55 
First, I want to say, this code is really really excellent.
 
I try to update the supergrid in run-time, such as, add or delete some columns, so first i call the function of SuperGrid "DeleteAll" but it just deletes items of list, not include columns. And then i modified the code in "CMySuperGrid" function "_DeleteAll"by the codes below:
 
void CMySuperGrid::_DeleteAll()
{
	DeleteAll();//call CSuperGridCtrl::DeleteAll();
        // here i add header deleting==============BEGIN
	CHeaderCtrl* pHeader=this->GetHeaderCtrl();
	int i, nCount=pHeader->GetItemCount();
	for(i=nCount-1; i>=0; i--)
		pHeader->DeleteItem(i);
 
	LPTSTR lpszCols[] = {_T("Tree thing"),_T("Column #1"),_T("Column #2"),_T("Column #3"),_T("Column #4"),_T("Column #5"),0};
	LV_COLUMN   lvColumn;
	//initialize the columns
	lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	lvColumn.fmt = LVCFMT_LEFT;
	lvColumn.cx = 200;
	for(int x = 0; lpszCols[x]!=NULL; x++)
    {
		//make the secondary columns smaller
		if(x)
		  lvColumn.cx = 150;
 
		lvColumn.pszText = lpszCols[x];
		InsertColumn(x,&lvColumn);
    }
        // here i add header deleting, and recreate columns==============END

	//add some new data
	CItemInfo* lp = new CItemInfo();
	lp->SetImage(4);
	//add item text
	lp->SetItemText(_T("New data"));
	//Create root item
	CTreeItem * pRoot = InsertRootItem(lp);//previous we call CreateTreeCtrl(lp)
	if( pRoot == NULL )
		return;
	//insert items	
	int nCol = GetNumCol();
	for(i=0; i < nCol; i++)
	{
		CItemInfo* lpItemInfo = new CItemInfo();
		CString strItem;
		strItem.Format(_T("Item %d"),i);
		//add items text
		lpItemInfo->SetItemText(strItem);
		//add subitem text
		for(int y=0;y < nCol-1; y++) 
		{
			CString str;
			str.Format(_T("subItem %d of %s"),y,lpItemInfo->GetItemText());
			lpItemInfo->AddSubItemText(str);
			lpItemInfo->AddSubItemText(str);
		}
		//insert the iteminfo with ParentPtr
		CTreeItem* pParent = InsertItem(pRoot, lpItemInfo);
		//other nodes
		if(i%nCol)
		{
			CTreeItem* pParent1=NULL;
			CTreeItem* pParent2=NULL;
			for(int x=0; x < nCol; x++)
			{
				CItemInfo* lpItemInfo = new CItemInfo();
				CString strItem;
				strItem.Format(_T("Item %d"),x);
				lpItemInfo->SetItemText(strItem);
				for(int z=0; z < nCol-1; z++) 
				{
					CString str;
					str.Format(_T("subItem %d of %s"),z, lpItemInfo->GetItemText());
					lpItemInfo->AddSubItemText(str);
				}
				pParent1 = InsertItem(pParent, lpItemInfo);
				
			}
		}
	}
	//expand one level
	Expand(pRoot, 0 /*listview index 0*/); 
	UINT uflag = LVIS_SELECTED | LVIS_FOCUSED;
	SetItemState(0, uflag, uflag);
}
but after this, readd columns and items, it shows some different, after drawing, there are columns at the end of the this new columns i created. how could i recreate the columns and items.

modified 20 Nov '11 - 13:34.

GeneralRe: How to real delete all, include column header?member@llan9 Dec '11 - 5:26 
cool, nice work.
cheers Allan Big Grin | :-D
Questionhow to add Icon To this SuperListmemberthanhl0v37 Mar '11 - 16:54 
i Get Icon of a process and i don't know to add it to SuperList
 

// on OninitDlg
m_List.SetImageList (CImageList::FromHandle (GetSystemImageList (FALSE)), LVSIL_NORMAL);
//a function
HIMAGELIST CTreeListDlg::GetSystemImageList(BOOL bLarge)
{
	SHFILEINFO sfi;
	UINT uFlag = bLarge ? SHGFI_LARGEICON : SHGFI_SMALLICON;
	return (HIMAGELIST) SHGetFileInfo (TEXT (""), NULL, &sfi, sizeof (sfi), SHGFI_SYSICONINDEX | uFlag);
}
//and i get Icon of process
int CShowProcessTree::GetIcon(LPTSTR szPath, UINT uFlags)
{
	SHFILEINFO sfi;
	//MessageBox(szPath);
	SHGetFileInfo (szPath, NULL, &sfi, sizeof (sfi), SHGFI_SYSICONINDEX | uFlags);
	return sfi.iIcon;
}
 
i saw your function SetImage(index) to get index Image from BitMap
 
but how to add Icon Process to...when i got icon of it?
 
i added successful in Tree..but when i use your control...i don't know how
can you give me a funtion to add Icon (i got from SystemIcon of that Process)
thanks so much
sorry if my english is not good
QuestionIs there a way to edit the fields?membermatt200023 Jan '09 - 9:03 
I'm looking for a way to group edit boxes with labels. I want to keep it simple. I could use a grid if I needed to, but this looks a lot cleaner.
 
Thanks!
QuestionDialog based application [modified]memberkrishnanand2 Jul '08 - 3:16 
can u please explain me how to do the same in dialog based application?I have seen how to use the SuperGrid in dialog based application.But there is no check boxes available for items in dialog .Also I don't want the image icons.Can u please guide me how to achieve these things?
 
modified on Thursday, July 3, 2008 12:50 AM

QuestionColumn problem when dynamic settingmemberEva ranee17 Sep '07 - 23:50 
before go into DrawItem(), I set the column with the item's length in LVN_GETDISPINFO process function OnGetDispInfo().
But there are some problem in DrawItem() that i can't find the reason.
[problem]
suppose i have follow data:
[+]ICON aaa
[+]ICON aaaa
[+]ICON aaaaa
 
DrawItem() first:
[+]ICON aaa
 
DrawItem() second:
[+]ICON aaa
___________a // before 'a', nothing
 
DrawItem() third:
[+]ICON aaa
___________a // before 'a', nothing
____________a // before 'a', nothing
 
have some idea? Thank you very much!
 

 
Follow the C++ technical

QuestionMultiple column sortinmembersharathgowda10 Jul '07 - 2:35 
Hi
 
this is really fantastic control. I really like this.
 
Does this support multiple column sorting....
 
sharath b
 
"The world's biggest power is the youth and beauty of a woman."

GeneralIt looks so good.memberN1i2c3k8 Jun '07 - 19:31 
It looks so good.Smile | :)
QuestionI need some help about delete itemsmemberStarsrain4 Apr '07 - 15:37 
my data is dynamic load from database,and i have carried it out only in the this
 
control.
my problem is i used the tree to control the data display in the list
tree control.On this way,i selchanged on the my tree control need display the data
 
in the list tree.at first,In my tree control selchange function i used the
 
deleteAll() function to delete the list tree all items and display the new
 
data.when i use the deleteall function the program will be intermitted. when i
 
used the DeleteAllItems() function to delete the list tree data,itself delete the
 
child node and display the child node function will be error.it display the data
 
not right.
like this:
+Root1
+Root2
+Root3
expend the Root1 then Root2 node will be delete and collapsed the Root1 it can't
 
delete itself children.
 
someone can help me or give me some suggestion,thanks
QuestionDo you have a VB OO compatible version or OCX ?memberMCMikey6921 Mar '07 - 7:40 
Hi,
 
This is fantastic and just what I need. However, I'm using VB6 to write my app (loads of very good reasons for that which I won't go into). Do you have the control compiled as an OCX?
 
Cheers,
Mike May
Big Grin | :-D
GeneralBug in check boxesmember_faraz12 Mar '07 - 0:48 
Settting the check in a root level item does not work. For example the following code addition to the demo (InitializeGrid method) fails to set the check:
 

CItemInfo* lp = new CItemInfo();
lp->SetCheck(1);
lp->SetImage(4);

//add item text
lp->SetItemText(_T("Hello World"));
//add subitem text
lp->AddSubItemText(_T("Happy"));
....
 

I'm hunting this bug down now...
 
faraz
GeneralRe: Bug in check boxesmember_faraz12 Mar '07 - 1:33 
To fix:
 
In CSuperGridCtrl::InsertRootItem(CItemInfo * lpInfo)
 
starting line 1488:
 
     CItemInfo* lp = GetData(pRoot);
     LV_ITEM lvItem;         
     lvItem.mask = LVIF_TEXT | LVIF_INDENT | LVIF_PARAM;
     CString strItem = lp->GetItemText();
     lvItem.pszText = strItem.GetBuffer(1);
     lvItem.iItem = GetItemCount();
     lvItem.lParam = (LPARAM)pRoot;
     lvItem.iIndent = 1;
     lvItem.iSubItem = 0;
     CListCtrl::InsertItem(&lvItem);
//Add this line in to let CListCtrl know about the check
     SetCheck(lvItem.iItem, lpInfo->GetCheck());
 
** Sometimes you know yourself something is a bad idea; follow your instinct Smile | :) **
 
                    //yes I know..have to maintain to sets of checkstates here...
                    //one for listview statemask and one for CTreeItem..but its located here so no harm done
                    SetCheck(ht.iItem,!GetCheck(ht.iItem));
                    CItemInfo *pInfo = GetData(pItem);
                    pInfo->SetCheck(!pInfo->GetCheck());
Questionhow do you implement it ?membershuaicarr25 Jan '07 - 18:24 
First,i should say thanks to your effort.i take advantage of your control in my own project. but i think the interface is too large to manipulate.
 
would you give me a description on how do you combine "LIST" with "TREE" ?
the tree like thing is in the first column .when a tree subitem collapses ,the relevent items in list acts accordingly . how does it work ?
QuestionNested List-Control with Column-Headers ?memberwebspektive7 Dec '06 - 4:34 
Do you have any plans to implement nested List-Controls or Supergrids instead of 'normal' rows (like FlyGrid.Net or Sandgrid) ?
GeneralReally useful but is it possible? [modified]membercrazydave2223 Oct '06 - 4:27 
Really useful but is it possible to add checkboxes to the SuperGrid in the dialog?
 
Do the controls work also in the dialog view?
Can't get them to work.
 
I would really appreciate anyones help?Sigh | :sigh:
 
I'm not daft, just stupid really!!!
 

-- modified at 8:12 Tuesday 24th October, 2006
Question1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?memberhawonjeon10 Oct '06 - 20:26 
1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?
 
^^dssfasdfadsafasdfasdfasdfasdf

AnswerRe: 1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?membertangshengye29 Oct '08 - 2:24 
I am waiting for this as well. Laugh | :laugh:
Generalproblem with add 100 000 nodesmembernikomsj14 Sep '06 - 3:16 
the tree are blinking and freeeze for many times when I trying to add 100 000 nodes ... I think that this can make better ... I remember one VirtualTreeView in C Builder that load 100 000 nodes for 2 seconds may we can take an idea from this ... If i have time I will try to improve it ...
 
nik
Generalbugmemberkingship9 Aug '06 - 6:32 
my list like:
+ RootItem0
|-Item01
|-Item02
|-Item03
|-Item04
+ RootItem1
|-Item11
|-Item12
|-Item13
|-Item14
+ RootItem2
|-Item21
|-Item22
|-Item23
|-Item24
 
when collapse all rootitems,like:
+ RootItem0
+ RootItem1
+ RootItem2
 
run search("Item13",NULL)
 
result like:
+ RootItem0
|-Item11
|-Item12
|-Item13
|-Item14 <--(selected)
- RootItem1
+ RootItem2
 
at this time,click "+" or "-" some other errors can be found.
 


GeneralNeed Some helpmemberkonstantinos_100028 Jul '06 - 0:42 
Dear All,
 
I am new in Visual C++. I use the Microsoft Visual C++ Version 6.0 and i have a small problem with the list control.
I cannot find a way (or i do not understand) how i could change the letter in specific lines with bolt and change at the same lines the text color and the background color.
Until now i am using the report style with a grid and i am load the data from a database.
I hope someone helps me as soon as possible.
Thans in advabce for your time.
Best regards,
Konstantinos.
Generalvery goodmemberbishanhu6 Jun '06 - 3:37 
This is a good ariticle,thanks for the author.
I used it,very nice to extend,simple interface,detailed example.I use it inherited from my own listctrl,to just make my list ctrl has the tree behavior.
thanks again.Smile | :)
Generalwrong version in the download linkmemberbanbanyy8 Feb '06 - 1:39 
the version in this page is the one updated in 14 july(by history text) .it doesnot support the subitem'image.
the newest version is 4 dec. where is it ?
Questionany one immplemented LVS_EX_HEADERDRAGDROP to this??memberkumar_anand8 Dec '05 - 23:19 
Hi;
If anyone has implemented this style,can u please post it here Big Grin | :-D ??
QuestionHow to use SetItemData?memberHarveyLiu14 Aug '05 - 17:49 
In listCtrl, we can use SetItemData to bound DWORD to every list item, but in this control, we can't do that, hope you can give those functions:SetItemData, GetItemData.;PLaugh | :laugh:
AnswerRe: How to use SetItemData?memberDanila Korablin25 Jun '07 - 5:34 
To set data use:
//...
CItemInfo *lpItem=new CItemInfo();
int <CODE>YourValue</CODE>=123;
lpItem->SetItemText(_T("Note"));
lpItem->m_lParam=<CODE>YourValue</CODE>;
m_listItem.InsertRootItem(lpItem);
//...
To get data (For example in OnNMDblclkGrid()):
//...
CTreeItem* pSelItem=m_listItem.GetTreeItem(index);
int <CODE>YourValue</CODE>=(int)pSelItem->m_lpNodeInfo->m_lParam;
//...

 
Wormhole is the God divided by zero

QuestionHow to change Parent ItemmemberTu Tran15 Jul '05 - 13:52 
Hi guru,
I am a newbie in C++ Programming. I am trying to use this control on my bill of material (BOM) program. I have a list of BOM (ParentNo, ChildNo, Description, etc) that I want to display using this control. So, I use loop (for i = ...) to loop through the list and InsertItem(ParentNo, ChildNo). How do I write the loop program to insert all the ChildNo using ParentNo as the Parent. Please Note: ParwentNo is not displayed, it's only used to specified where the ChildNo belonged to. Thank you for all your help and suggestion.
 
Tom.
 

Generalset check box after iconsmembersammmmmy7 Jul '05 - 23:55 
How do i set the check boxes after the icons ?
Most of lists do that way.
THX
GeneralRe: set check box after iconsmembersammmmmy8 Jul '05 - 0:06 
Ooopss, I made a mistakae, i wanted to say check boxes before icons.
Thx
Generalvery good,Thaknsmemberhpxs21 Jun '05 - 17:08 
Cool | :cool: very good,ThaknsRose | [Rose]
QuestionHow can I realize the directory tree like the listview?memberblestrabbit13 Apr '05 - 17:02 
I want to realize the directory tree like the listview.Beacuse I want to realize the directory tree, I just know how to realize the tree not other function code.But I can't to understand where to construct the tree in the project.
 
Pls help me.
 
Thanks!
QuestionHow to do sorting depending on column data type?memberNikoletinaBursac8 Mar '05 - 7:43 
I want to be able to sort list by clicking on a column header. It should sort depending on column data type.
I am beginner in C++..Smile | :)
But I like control, a lot. It reminds me of Delphi control I like (ELTreeView from LMD Tools)
GeneralDifferent Item Heightmemberhypercor17 Feb '05 - 1:20 
How can one set different Item-Heights? default is only one Height for alle Items.
 


 
ITZ-MEDICOM
GeneralRe: Different Item Heightmemberiliyang16 Jun '05 - 9:20 
Does anyone have an idea how to set different height of the items, pleease?
Generalmoving rowssussmeir_elkabetz@hotmail.com16 Feb '05 - 4:13 
Hi,
first I want to thanks the developer. you saved me a lot of time.
I have worked a lot on this listctrl but I just couldn't replace two raws in
the list. I added two buttons for moving a selected raw Up and Down.
 
Does anyone achived such a thimg?
 
Uv
Questionhow can set a col is readonlysussAnonymous3 Nov '04 - 18:41 
how can set a col readonly?
GeneralA Definite BugsussBill Ross29 Sep '04 - 7:30 
Hi;
 
I'm popping up a dialog containing only a CComboBoxEx in response to a column RClick. The last ComboboxEx list item text (as soon as DoModal on dialog) appears in all supergrid cells (in created rows) that have not been initialized with text or have been initialized with _T(""). The reason for the popup (rather than using a cell Listbox) is for UI consistency with other cells which require more complex dialogs.
The workaround to this is to initialize all column cells with _T(" ") at row creation.
If anyone wants to look into this, let me know and I will put together a simple test case.
 
Regards;
Bill
 

QuestionCan I use this in .net visual c++memberChetan.M22 Sep '04 - 21:22 
Hi..
 
Can I use this control wrapped in managed user control in .net windows ???
 
I have tried it but i cannot get the display since DrawItem and MeasureItem is not called ... i think some message handler is corrupt or i have intialize it manually
 
can any one help
 
Chetan.M
GeneralSorting is kinda weakmemberLakeFerrits10 Aug '04 - 11:15 
I have been using this control for a while and it works nicely once you understand it, but it seems there is no way to sort on the root items. Try it in the example. You'll see that the top most root items don't sort. Only the children do.
 
I added some code to try to fix this problem, by calling CListView::SortItems() and then swapping the corresponding CTreeItem pointers among each LV_ITEM in the view. It does sort, but the children don't show correctly when the +/- signs are clicked.
 
Anyone figure this one out?
GeneralVERY hard to usememberjtorjo19 Jul '04 - 22:05 
I'm sorry to say - but while I'm sure you've worked a lot on it, and the UI looks great -,
 
IT IS EXTREMELY HARD TO USE IN REAL APPS.
 
In fact, it made my life a nightmare to use (I've worked on a project that used this class, and needed to customize the UI).
 
I would suggest you provide a MUCH simpler interface . The current one is way too big, hard to understand, and error prone.
 
Especially, what really killed me, was the fact that when the user clicks a "Collapse" button, my list items are DELETED. Thus, I needed to create an extra wrapper to somewhere hold references to their text.
Then, I had to create a custom mechanism for uniquely identifying an item in such a Super Grid (since the item's index wouldn't work)
 


 
John Torjo
Freelancer
-- john@torjo.com
 
Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/

Professional Logging Solution for FREE
-- http://www.torjo.com/code/logging.zip (logging - C++)
-- http://www.torjo.com/logview/ (viewing/filtering - Win32)
-- http://www.torjo.com/logbreak/ (debugging - Win32)
(source code available)

GeneralRe: VERY hard to usemember@llan25 Feb '05 - 21:02 
>I'm sorry to say
hey don't beD'Oh! | :doh:
>but while I'm sure you've worked a lot on it, and the UI looks great -,
I worked on this 3 weeks in 1999 and I am sorry I didn't factored the interface back then, I was in a hurry...and I figured perhaps someone else could use this code, so I uploaded it here...Rose | [Rose]
>Especially, what really killed me, was the fact that when the user clicks >a "Collapse" button, my list items are DELETED
you actually did not take the time to read the article, did you now Poke tongue | ;-P
>Then, I had to create a custom mechanism for uniquely identifying an item
Confused | :confused:
I hope your nightmares are over Smile | :) .
 
I am sorry that you didn't get a free ride with this control here.Big Grin | :-D
 
keep up the good work.

GeneralRe: VERY hard to usememberjtorjo26 Feb '05 - 8:58 
Sorry for the harsh words - I was very angry at that time. You must have put a lot of effort in it.
 
I still think the interface is too huge, and perhaps it could benefit greatly from templates Smile | :)
 
Best,
John
 

 

 

--
John Torjo, Contributing editor, C/C++ Users Journal
-- "Win32 GUI Generics" -- generics & GUI do mix, after all
-- http://www.torjo.com/win32gui/ -v1.6.3 (Resource Splitter)
-- http://www.torjo.com/cb/ - Click, Build, Run!
 

GeneralThis is VERY difficult to customizememberbrchris19 Jun '04 - 8:25 
[snipped a useless rant]
 
Nevermind! I'm stupid. and a jerk. Sorry. You must have spent a lot of time working on this and it does look great, when I can get it work. There is a little bit of overhead in getting this to work for in an application, but other than that I think it looks great.
 
However this question still stands. Also, what if you don't want images in the tree control?
 
I may fiddle with this and check. It seems whenver I eliminate the images the plus boxes also go away. Any attempt to doctor that space and the plus bozes get changed. Kinda a headache.
 
But good work! Thanks for sharing!
 

Thanks!
GeneralRe: This is VERY difficult to customizememberbrdavid5 Mar '05 - 8:43 
Not sure what I was thinking here. Yeah... would have been nice if I just posted the silly fix. Here is DrawItem. Look for the variable "m_NoImages". this variable is set by me if I have images or not. if not, I am commenting out code that deals with them. I've cut out some stuff to help with length. Hopefully it makes sense.
 
void CSuperGridCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	if (lpDrawItemStruct->CtlType != ODT_LISTVIEW)
        return;
 
	if(lpDrawItemStruct->itemAction == ODA_DRAWENTIRE)
	{
	        ...	
 
	
		CRect rcClip = lpDrawItemStruct->rcItem;
 
		if(m_NoImages)
			rcClip.left -= 20;
 
		rcClip.left += GetIndent(pSelItem) * m_cxImage + m_cxImage + 2;
		if(rcClip.left > GetColumnWidth(0))
			rcClip.left = GetColumnWidth(0);
		//fill background color
		
		ExtTextOut(pDC->GetSafeHdc(), 0, 0, ETO_OPAQUE, CRect(0, rcClip.top, rcClip.right, rcClip.bottom), NULL, 0, NULL);
	
		if((nWidth=m_cxImage-nWidth) >-1)//calc width of icon
		{
			if(!m_NoImages)
			{
				ImageList_DrawEx(m_himl, lvi.iImage, pDC->m_hDC,  
								rc.left + (GetIndent(pSelItem) * m_cxImage), 
								nY, 
								nWidth,	
								m_cyImage,
								CLR_DEFAULT, 
								CLR_DEFAULT, 
								uiFlags);
			}
			DrawTreeItem(pDC, pSelItem, nItem, rc);
		}
 
                ...
 

		//draw 1. item	
		GetItemRect(nItem, rcItem, LVIR_LABEL);
		pszText = MakeShortString(pDC, szBuff, rcItem.right - rcItem.left, 2*OFFSET_FIRST);
		rcLabel = rcItem;
		
		pDC->SetBkColor (crBackground);
		pDC->SetTextColor (crText);
 
		rcLabel.left+=OFFSET_FIRST;
		rcLabel.right-=OFFSET_FIRST;
 
		if(m_NoImages)
			rcLabel.left -= 20;
 
		pDC->DrawText(pszText,-1, rcLabel,DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_EXTERNALLEADING);
 
                ...
 
	}//ODA_DRAWENTIRE
}
 
Here a screen clip
from an application i am currently designing that shows the grid without the icons.

i have been working with this control quite a bit and have a LOT of logic changes and bug fixes. If the author would like a copy of my files I will send them. It's hard to put everything into this comment board. Also, I forgot many of the changes I put in. Smile | :) I don't comment as much as I should. Smile | :)
GeneralRe: This is VERY difficult to customizesussicecube418 Feb '05 - 9:06 
brdavid wrote:
I have a fix for anyone who wants to eliminate the icons that appear in the listview control.
 
Nice screen shot, but where can i find the fix?
 
Would be great if you share it.
GeneralEasy way to place this in custom appsussAnonymous5 Jun '04 - 0:48 
Is there an easy way to place this in a different app?
QuestionHow to use CTreeItem class and its member function in SuperVw class?memberbenax.von19 May '04 - 22:18 
I want to open a file include some data ,and show it in the root item of list,any suggestion?
GeneralUsing this control without ImageListmemberJimmyO19 May '04 - 4:11 
Hello,
This control don't work without SetImageList.
Is there a solution ?
 
Jimmy
GeneralControl flckers during column resizememberHarnash12 May '04 - 4:19 
Does anyone know how to get rid the flicker effect during resize of the columns. It is really annoying.
GeneralRe: Control flckers during column resizememberMartin Richter19 May '04 - 2:11 
I do not have any flickering when I resize a columns. Is this reproducable with the Demo code?
Martin

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 9 Dec 1999
Article Copyright 1999 by Allan Nielsen
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid