|
|
Comments and Discussions
|
|
 |

|
I hope this will help Hack you day in your project, and this class more Valuable.
=>First. Bug Fix at InsertRootItem in SuperGridCtrl.cpp
At function: CSuperGridCtrl::InsertRootItem(CItemInfo * lpInfo)
.....
lvItem.iSubItem = 0;
CListCtrl::InsertItem(&lvItem); //after line 1497
Add this code:
SetCheck(lvItem.iItem, lpInfo->GetCheck());
=>Second add new function SetCheckStateItem() in MySuperGrid.cpp
void CMySuperGrid::SetCheckStateItem(CTreeItem* PItemX, BOOL bState)
{
int indexP = GetCurIndex(PItemX);
SetCheck(indexP,bState); CItemInfo *pInfo = GetData(PItemX);
pInfo->SetCheck(bState); return;
}
=>Third. Capture ChecBox event Left click By NM_CLICK message in MySuperGrid.cpp
Since it’s in control, we using ON_NOTIFY_REFLECT .
ON_NOTIFY_REFLECT(NM_CLICK, OnGridLClick)
Header:
afx_msg void OnGridLClick(NMHDR *pNMHDR, LRESULT* pResult);
implementation function:
void CMySuperGrid::OnGridLClick(NMHDR *pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
LVHITTESTINFO ht;
ht.pt = pNMListView->ptAction;
CPoint point = ht.pt;
SubItemHitTest(&ht);
BOOL bItemSel=0;
bItemSel = HitTestOnSign(pNMListView->ptAction,ht);
if(bItemSel && ht.iSubItem == 0)
{
if(ht.flags == LVHT_ONITEM && (GetStyle() & LVS_OWNERDRAWFIXED))
{
CRect rcIcon,rcLabel;
GetItemRect(ht.iItem, rcIcon, LVIR_ICON);
GetItemRect(ht.iItem, rcLabel, LVIR_LABEL);
if (point.x > rcIcon.left && point.x < rcLabel.left)
{
CTreeItem* pItem = GetTreeItem(ht.iItem);
if(pItem!=NULL)
{
CItemInfo* lp;
lp = GetData(pItem); if(lp->GetCheck()) {
SetCheckStateItem(pItem, FALSE);
Beep(2000,50); }
else
{
SetCheckStateItem(pItem, TRUE);
Beep(4000,50); }
}
}
}
}
return;
}
CMIIW..
Regards,
indonesian C++ community.
modified 8-Jun-13 9:32am.
|
|
|
|

|
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.
|
|
|
|

|
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(); 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;
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++)
{
if(x)
lvColumn.cx = 150;
lvColumn.pszText = lpszCols[x];
InsertColumn(x,&lvColumn);
}
CItemInfo* lp = new CItemInfo();
lp->SetImage(4);
lp->SetItemText(_T("New data"));
CTreeItem * pRoot = InsertRootItem(lp); if( pRoot == NULL )
return;
int nCol = GetNumCol();
for(i=0; i < nCol; i++)
{
CItemInfo* lpItemInfo = new CItemInfo();
CString strItem;
strItem.Format(_T("Item %d"),i);
lpItemInfo->SetItemText(strItem);
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);
}
CTreeItem* pParent = InsertItem(pRoot, lpItemInfo);
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(pRoot, 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:34pm.
|
|
|
|

|
cool, nice work.
cheers Allan
|
|
|
|

|
i Get Icon of a process and i don't know to add it to SuperList
m_List.SetImageList (CImageList::FromHandle (GetSystemImageList (FALSE)), LVSIL_NORMAL);
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);
}
int CShowProcessTree::GetIcon(LPTSTR szPath, UINT uFlags)
{
SHFILEINFO sfi;
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
|
|
|
|

|
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!
|
|
|
|

|
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
|
|
|
|

|
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
|
|
|
|

|
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."
|
|
|
|

|
It looks so good.
|
|
|
|

|
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
|
|
|
|

|
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
|
|
|
|

|
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
|
|
|
|

|
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 ** //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());
|
|
|
|

|
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 ?
|
|
|
|

|
Do you have any plans to implement nested List-Controls or Supergrids instead of 'normal' rows (like FlyGrid.Net or Sandgrid) ?
|
|
|
|

|
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?
I'm not daft, just stupid really!!!
-- modified at 8:12 Tuesday 24th October, 2006
|
|
|
|

|
1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?
^^dssfasdfadsafasdfasdfasdfasdf
|
|
|
|

|
I am waiting for this as well.
|
|
|
|

|
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
|
|
|
|

|
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.
|
|
|
|

|
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.
|
|
|
|

|
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.
|
|
|
|

|
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 ?
|
|
|
|

|
Hi;
If anyone has implemented this style,can u please post it here ??
|
|
|
|

|
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.;P
|
|
|
|

|
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
|
|
|
|

|
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.
|
|
|
|

|
How do i set the check boxes after the icons ?
Most of lists do that way.
THX
|
|
|
|

|
Ooopss, I made a mistakae, i wanted to say check boxes before icons.
Thx
|
|
|
|
|

|
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!
|
|
|
|

|
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++..
But I like control, a lot. It reminds me of Delphi control I like (ELTreeView from LMD Tools)
|
|
|
|

|
How can one set different Item-Heights? default is only one Height for alle Items.
ITZ-MEDICOM
|
|
|
|

|
Does anyone have an idea how to set different height of the items, pleease?
|
|
|
|

|
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
|
|
|
|

|
how can set a col readonly?
|
|
|
|

|
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
|
|
|
|

|
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
|
|
|
|

|
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?
|
|
|
|

|
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)
|
|
|
|
|

|
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
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!
|
|
|
|

|
[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!
|
|
|
|

|
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);
ExtTextOut(pDC->GetSafeHdc(), 0, 0, ETO_OPAQUE, CRect(0, rcClip.top, rcClip.right, rcClip.bottom), NULL, 0, NULL);
if((nWidth=m_cxImage-nWidth) >-1) {
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);
}
...
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);
...
}}
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. I don't comment as much as I should.
|
|
|
|

|
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.
|
|
|
|

|
Is there an easy way to place this in a different app?
|
|
|
|

|
I want to open a file include some data ,and show it in the root item of list,any suggestion?
|
|
|
|

|
Hello,
This control don't work without SetImageList.
Is there a solution ?
Jimmy
|
|
|
|

|
Does anyone know how to get rid the flicker effect during resize of the columns. It is really annoying.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A combination list control and tree control with checkbox capability
| Type | Article |
| Licence | CPOL |
| First Posted | 26 Nov 1999 |
| Views | 559,005 |
| Downloads | 6,097 |
| Bookmarked | 305 times |
|
|