|
|
Comments and Discussions
|
|
 |

|
wtl CImageList class no destructor, must call Destroy() to run ImageList_Destroy.
~CListImpl()
{
m_ilListItems.Destroy();
m_ilItemImages.Destroy();
}
modified on Sunday, July 3, 2011 2:58 AM
|
|
|
|

|
I show the "ListCtrl" in a model dialog, and Close the model dialog each time the GDI object will increase of 4, Why?
|
|
|
|

|
Is it possible to search a column for a value without looping through all rows in the control? In other words, search the item / subitem array structure directly for the desired value? Thanks, Dave
|
|
|
|

|
Hi!
First of all, very nice work, thanks a lot for the demo!
When running the demo everything works out fine, until now no problems for me
But when I exit the demo the compiler complains about serveral "first-chance exceptions"
at various memory locations. In the output window it shows around 50 lines like these:
First-chance exception at 0x76a6b08e in ListCtrlDemo.exe: Microsoft C++ exception: Error at memory location 0x0012b700..
What does this mean, has anyone got an idea?
I tries to put this line as the last one in the main methos:
AtlDumpMemoryLeaks();
Together with this include statement before other ATL includes:
#include
However, I can't get this check up and running because it complains a lot about perceived problems in the GDI+ files... And I couldn't find any support for this feature on the net...
All in all, can anyone help me with the two mentioned questions?
1) the various first-chance exception, and
2) how to use the AtlDumpMemoryLeaks() tool correctly.
Thanks in advance!
Robert
|
|
|
|

|
Thank you for sharing
I'm so Poor,so I must work hard.
|
|
|
|
|
|

|
Thanks again for this great control.
I saw an earlier message where it seemed to say that use of this control in commercial software was ok.
Is that correct, and can this be used in a closed source commercial product?
Is this source code released under any specific licence?
John
|
|
|
|

|
I couldn't find a way to make it show a multi-line edit control. Maybe I just didn't try hard enough?
I love the control--it looks great. But without the multi-line option, I can't use it in my project.
|
|
|
|

|
I must confess I haven't read the article yet. I've read some other articles on Code Project, and then downloaded the code, only to be disappointed.
I'm sure I'm not the only one who runs the code first, then reads. No run, no read.
It's fast and small. And no MFC! Woohoo! Since I don't maintain old code, I don't need an MFC version.
I compiled on VS 2008 with WTL 8.0:
Worked fine; had to change one line in ListCtrl.h:
Ln 2542:
Before:
OnTimer( UINT nIDEvent, TIMERPROC timer )
After:
OnTimer( UINT nIDEvent )
Thanks!
|
|
|
|

|
...will remember your article, when I need a customized list control.
And by the way, I am with you on the .net vs. WTL issue. Back in 2002, I was deciding whether to use .net or WTL for a bigger project and thanks God I have chosen WTL. .net takes away too much .
|
|
|
|

|
#include
dont exists dont work, more headers as source its trash in my view
|
|
|
|

|
1. DrawCustomItem must be virtual to correct overriding:
virtual void DrawCustomItem( CDCHandle dcPaint, int nItem, int nSubItem, CRect& rcSubItem )
{
ATLASSERT( FALSE ); // must be implemented in a derived class
}
2. instead of
// custom draw subitem format
if ( nItemFormat == ITEM_FORMAT_CUSTOM )
{
pT->DrawCustomItem( dcPaint, nItem, nSubItem, rcSubItem );
return;
}
should be:
// custom draw subitem format
if ( nItemFormat == ITEM_FORMAT_CUSTOM )
{
pT->DrawCustomItem( dcPaint, nItem, nSubItem, rcSubItem );
continue;
}
|
|
|
|

|
Hi!
Very useful control, thanks!
But I think I've found the small bug in OnRButtonUp handler.
void OnRButtonUp( UINT nFlags, CPoint point )
{
int nItem = NULL_ITEM;
int nSubItem = NULL_SUBITEM;
if ( !HitTest( point, nItem, nSubItem ) )
ResetSelected();
// notify parent of right-click item
NotifyParent( nItem, nSubItem, LCN_RIGHTCLICK );
}
So, when nothing is selected it passes a garbage to LCN_RIGHTCLICK handler, because HitTest modifies nItem and nSubItem values.
I think, it should look something like this:
void OnRButtonUp( UINT nFlags, CPoint point )
{
int nItem = NULL_ITEM;
int nSubItem = NULL_SUBITEM;
if ( !HitTest( point, nItem, nSubItem ) )
{
nItem = nSubItem = NULL_ITEM;
ResetSelected();
}
// notify parent of right-click item
NotifyParent( nItem, nSubItem, LCN_RIGHTCLICK );
}
Thanks, Serge.
|
|
|
|

|
Thank you very much for the great control.
When changing ITEM_HEIGHT_MARGIN to smaller value (in order to decrease row height), the appearance is not very nice (especially when editing). Do we have any way to workaround?
|
|
|
|

|
BoundChecker says "Object is selected in to a DC , DeleteObject".
This happened in "Line 3288 in ListCtrl.h"
I was confused, CPen delete the m_hPen in destructor,so it appears above problem, but if I change the code into explicit call DeleteObject,the program crash,on the other hand I try use CPenHandle instead,but BoundsChecker says "GDI Resource memory leaks"..... so should it be a problem?
|
|
|
|

|
Hello,
Thanks a lot for sharing your code.
Please, I'd like to ask you:
1.when i input some particular character / : * ? < > | \ etc ,then i want clue to user this is not allowed. like the windows that when you change your filename .now I want use CToolTipCtrl ,can you given me a directionsbreak?
2.that is about progress ,i want show the percent on the progress . how to implement??
waiting for your answer;
|
|
|
|

|
never mind..
-- modified at 17:59 Monday 9th July, 2007
|
|
|
|

|
I use VS 2005 SP1. After the solution is converted to VC8
the error appears in both WTL7.5 and WTL8 during the compilation.
The reason of this error is clear: Macros of the kind MSG_WM_XXXX
take function with one argument only as a parameter, whereas
OnTimer here has the second argument -- TIMERPROC timer.
If one deletes this argument from the definition of OnTimer()
(or just one sets default value NULL for it), two other error messages appear, completely unrelated with timer: "two overloads for div()".
By the way, this is not the only program which fails to compile
due to the same reason -- all other demos defining OnTimer() via
MSG_WM_TIMER macro fail to compile as well.
Only WTLntrayDemo compiles OK, but it uses MESSAGE_HANDLER macro
instead of MSG_WM_TIMER to define OnTimer(). Which depends here
on 4 "non-cracked" arguments.
|
|
|
|

|
How to use your listview control as a view in MDI mode?
|
|
|
|

|
Hello,
Thanks a lot for sharing your code.
Please, I'd like to ask you:
1. when running your application on Vista, you're sure that the blue gradient you're using for highlighting the background of the selected listview rows, is exactly the same as used by the Windows Explorer for example ?
2. when running your application on Vista, can the blue gradient used for highlighting the background of the selected listview rows, be painted by using themes API functions like DrawThemeBackground(), instead of using the GradientFill() function with the GRADIENT_FILL_RECT_V parameter ?
Thanks a lot.
Do you any know of an article or web references describing how the Microsoft programmers implemented this highlighting of the selected listview rows background?
-- modified at 10:28 Monday 2nd April, 2007
|
|
|
|

|
Hi.
I have some quistion about DnD
I've found classes, which describes interfaces for DnD, but I don't found any use of it.
I never use DnD later, and I don't understand how to implement this classes for work with this ctrl.
Second: Why DnD occure only when I try to select group in first column (0)?
I think that DnD would work like:
one item: click for select, and next ms_down+ms_move = drag;
multiple items: ms_down+ms_move - select rectangle, and other ms_down+ms_move - drag.
Right?
|
|
|
|

|
Hi,
This is a great control - thumbs up !!
Is it possible to see the MFC version (if one exists) ?
Thanks,
Guy.
|
|
|
|

|
First of all thanks for this fantastic control by Alan.
I'd like to utilize it for a simple MFC based applicaton but failed. Here is what I did:
1. Create MFC application using VS 2005 Wizard
2. merge stdafx.h
Compile error as below:
------ Build started: Project: Test, Configuration: Debug Win32 ------
Compiling...
stdafx.cpp
c:\wtl75\include\atluser.h(413) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atluser.h(567) : see reference to class template instantiation 'WTL::CMenuT' being compiled
c:\wtl75\include\atlgdi.h(2583) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlgdi.h(3292) : see reference to class template instantiation 'WTL::CDCT' being compiled
c:\wtl75\include\atlgdi.h(2583) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlgdi.h(3302) : see reference to class template instantiation 'WTL::CDCT' being compiled
with
[
t_bManaged=true
]
c:\wtl75\include\atlmisc.h(3086) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3316) : see reference to class template instantiation 'WTL::CRecentDocumentListBase' being compiled
c:\wtl75\include\atlmisc.h(3086) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3319) : see reference to class template instantiation 'WTL::CRecentDocumentListBase' being compiled
with
[
T=WTL::CRecentDocumentList
]
c:\wtl75\include\atlmisc.h(3453) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3464) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3476) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3493) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3502) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3457) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3468) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3480) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3481) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3497) : error C2039: 'CString' : is not a member of 'ATL'
c:\wtl75\include\atlmisc.h(3506) : error C2039: 'CString' : is not a member of 'ATL'
Build log was saved at "file://e:\temp\Test\Debug\BuildLog.htm"
Test - 16 error(s), 0 warning(s)
|
|
|
|

|
Thanks a lot for this great article.
But you have to fix few memory leaks.
I think you have to remove all the array elements in
destructors:
struct CSubItem
{
~CSubItem()
{
m_aComboList.RemoveAll();
...
struct CListItem
{
~CListItem()
{
m_aSubItems.RemoveAll();
...
Thanks again.;)
|
|
|
|

|
Subj. Greate job!
Thanks!
|
|
|
|

|
i have tried to build the demo project in VC7.1 and VC8.0
and it shows 38 compile-time errors mostly about missing storage
classes. Shouldn't the demo work? Am i forgeting something? thx
|
|
|
|

|
it showing error that it can't open include file #include
do i have to set any properties .
thanks in advance
|
|
|
|

|
Thanks for your excellent work.
|
|
|
|

|
Congratulations on that one!
I'd just like to express that i feel the same way about c# and good old c++. You get stuff done with c# that's for sure. But somehow i'm always tempted to start a native c++ project again where everything responds quickly and users feel the power underneath. with c# & windows forms I produce applications that look nicer but i know that their native c++ counterpart would be somehow more 'solid'.. whatever that means exactly. more thoroughly designed maybe.
very good to see people still embracing c++ and the WTL. makes me feel a little more comfortable.
|
|
|
|

|
it is really a control i have dreamed.....
|
|
|
|
|

|
Subj. (using multiselection mode).
Thanks.
|
|
|
|

|
Hi, your wtl control is great, but I can't create a modeless dialog with it. any ideas?
Thanks,
Lee
-- modified at 17:55 Thursday 17th August, 2006
|
|
|
|

|
great control!
thank you!
can this control support virtual mode?
|
|
|
|

|
Hi
I've noticed two problems with the (otherwise great!) control.
.SetFont doesnt seem to have any effect.
m_List.SetFont(m_fntCustomFont1, TRUE); // this doesnt do anything.
And
Although, SetItemFont does work when you hover over a hyperlink column the font goes back to default.
--
Thanks
Ben
|
|
|
|

|
What a fantastic control - cheers!
Does anyone know how to implement a button column. I'd like to embed a stanard button in a column and be able to handle each button's click event.
--
Thanks
Ben
|
|
|
|

|
Kudos:
Excellent control, I respect your programming as only a fellow custom control creator can!
Suggestions & bug fixes:
Mostly my comments and suggestions below are about encapsulation. Specifically I wanted to treat your control as a "black box" and not have to modify my code other than including a couple of files. What I did was to create a new dialog-based WTL application and then quickly try to change a ListView control to your control. This did not work straight away so I made changes to your code and tried to keep a journal (below). Other than the memory leak these are just comments and you should most certainly take every one of them with a grain of salt.
1) Turn on warning level 4. This is just a good idea for too many reasons but the most important is that it keeps you honest with your compiler. Why MS doesn't turn this on by default baffles me. I went so far as to write an extension for VS 2005.NET that will turn it on for all projects automatically.
2) Wrap all unused formal parameters in comments - i.e.:
MyFunction(bool bMyUsedVar, bool /*bMyUnusedVar*/, bool bMyOtherUsedVar)
to get rid of all "warning C4100: 'MyUnusedVar' : unreferenced formal parameter" messages. There are just tons of these and they will fill the build output window (easy to trace down yourself, only took me a few minutes to stomp out all of them entirely).
2-b) remove initialized but unused local variables:
CListImpl::SortColumn()
BOOL bReverseSort = FALSE; <= This guy
3) Add to DropArrows.h:
#include <atlcrack.h> // MSG_WM_DESTROY, etc.
4) Move define for END_MSG_MAP_EX out of stdafx.h and put where needed:
#define END_MSG_MAP_EX END_MSG_MAP at the top of ListCtrl.h, ListDate.h, ListCombo.h, ListEdit.h, TitleTip.h, DropArrows.h
5) Change some CRects to RECTs
DropArrows.h
~line 40:
RECT rTemp;
::SetRect(&rTemp, 0, 0, m_bVertical ? 12 : m_nSpanLength, m_bVertical ? m_nSpanLength : 12 );
if ( CWindowImpl< CDropArrows >::Create( hWndParent, &rTemp, NULL, WS_POPUP | WS_DISABLED, WS_EX_TOOLWINDOW ) == NULL )
~line 105:
RECT rTemp;
::SetRect(&rTemp, 0, 0, m_bVertical ? 12 : m_nSpanLength, m_bVertical ? m_nSpanLength : 12);
dcErase.FillRect(&rTemp, m_bshArrowBrush );
ListCombo.h
RECT rTemp = {( ( dwStyle & CBS_DROPDOWNLIST ) == CBS_DROPDOWNLIST ) ? rcRect.left + 3 : rcRect.left + 1, rcRect.top, rcRect.right, rcRect.bottom + ( 6 * rcRect.Height() )};
if ( CWindowImpl< CListCombo, CComboBox >::Create( hWndParent, &rTemp, NULL, dwStyle ) == NULL )
ListDate.h
RECT rTemp = { rcRect.left + 3, rcRect.top + 2, rcRect.right - 3, rcRect.bottom - 2 };
if ( CWindowImpl< CListDate, CDateTimePickerCtrl >::Create( hWndParent, &rTemp, NULL, dwStyle ) == NULL )
6) Remove references to IDC_DIVIDER (replace with system cursor IDC_SIZEWE)
7) check for divide by 0 in ListCtrl.h "GetTopItem" method:
int GetTopItem()
{
int iRetval = 0;
if(m_nItemHeight)
iRetval = (int)( GetScrollPos( SB_VERT ) / m_nItemHeight );
return iRetval;
}
8) Consider using the pointer declaration (*) like you use the reference declaration (&). i.e.:
char* pszMyVar;
instead of
char *pszMyVar;
or perhaps the other way around, but consistency would be nice. I know this is a style issue and borderlines religious so please don't be offended.
9) Memory Leak in CDragDrop class: m_pDropTarget is not free'd:
Check your CDragDrop::Register method, look for:
if ( FAILED( RegisterDragDrop( m_hTargetWnd, m_pDropTarget ) ) )
and add a
delete m_pDropTarget; inside the if clause {}
I am guessing that you should also put a:
if(m_pDropTarget)
delete m_pDropTarget;
in your destructor too, but I admit that I don't know (don't care) why RegisterDragDrop is returning a failure in my code. I didn't go out of my way to turn DragDrop on or off, I am just using your code "out of the box" and I am not interested in the feature at this time.
10) I didn't come up with a clever way to remove the necessity for the "IDB_LISTITEMS" image list or the IDC_HYPERLINK cursor yet, but I will some day. In the past I have gone as far as declaring a cursor as two static globals in RAM (cursor and mask) and then calling "CreateCursor" with pvANDPlane and pvXORPlane parameters - kind of brute-force but it works like a champ from Windows 95 and up.
Finally:
And you should be quite proud, this control is a great accomplishment!
|
|
|
|
|

|
The standard list control supports shared image list (with attribute LVS_SHAREIMAGELISTS).
Could you please add this feature into your control?
|
|
|
|

|
This is a great control; every u/i should have at least one! I played with it for a little while and it worked great. Moreover, it worked as indicated in the clearly written description. And it worked the first time !
Incidentally, I ressonated with your comments on C# not being exciting. I have tried it too but the whole CLR thing, while extremely useful, no doubt about it, it failed to excite me. Don't know why. So I went back to C++. As I said, your comments ressonated with me; I wonder if this is a widely held feeling among C++ developers or just a minority. Anyway, congratulations for the great work and thanks for sharing it with us.
|
|
|
|

|
Hi,
I was very impressed with this control. Thanks for your job.
But, when I first started sample project on my WinXP with "Windows Classic" theme enabled then no Vista style was shown - only standard Windows selection. But tooltips were working correctly: they were changing appropriately when I pressed Theme button.
Then I changed Windows theme to "Windows XP" and everything began to work correctly.
Is it possible that Vista style selection was available for any theme of Windows, e.g. as your Vista-style Tree Control is doing?
Regards,
Pasha
|
|
|
|

|
It appears that the file is no longer available? Is it available somewhere else?
|
|
|
|

|
I'm a total beginner to the world of programming, so you'll have to forgive me if I'm asking for something impossible/against license restrictions!
This control looks amazing, and is exactly what I've been looking for... but I'm using C++ Express, and I just can't get it to work. I've downloaded the Microsoft SDK and WTL, but it keeps asking for more .h files, like atlstr.h, and also throws up some messaged about depreciated functions. I've enjoyed poking my way through the code in an attempt to understand it all, but I've got some pressure to actually return something useful soon!
Is it possible to provide the control as a compiled DLL to use a reference in another project, or does its nature mean this can't happen?
Cheers!
|
|
|
|

|
Vista Experiance....Thanks, but no thanks...
Ever since some wet behind the ear kid decided to flatten everything I have not enjoyed the Windows UI, and now this !
This link better explains what Microsoft is trying to dump on us (again) !
http://msdn.microsoft.com/windowsvista/experience/#newvisuals
It appears to be the same crowd (at Microsoft) that took away Class Wizard (VS6) and told me VS2003 would make me more productive !
Taking away Class Wizard added several hundred more mouse moves and mouse clicks during a normal days work. Taking away Class Wizard did not improve my work experience, in fact the extra mouse use caused my carpal tunnel to flare up... So my new experience with VS is pain with every mouse click... Thanks Microsoft I needed that !
Goal #1 should be to make Windows stable ! I agree it's getting better... however it's far from trustworthy. Before anyone jumps in and recommends other OS's like Apple or Linux.... get a life! that stuff is no better... I'm not anti Microsoft or BG, in fact I love the stuff, however sometimes there comes a time where even loyalists have to say STOP and re-think... That time came with the flat look, and now vista ! Oh! NO....
|
|
|
|

|
You made it this far....
I'm stil trying to figure out what "Windows Vista style" is !;P
Thanks
|
|
|
|

|
When I select items from the bottom of the list(not on the item), Keep the Left button down and move mouse to select some items.
The func GetSelectedItems( CListArray < int >& aSelectedItems ) will make a mistake. values stored in aSelectedItems is wrong.
I've checked the codes , "int nTopItem = GetTopItem()" (in void AutoSelect( CPoint point )) will return -1?
|
|
|
|
|

|
Great control. It's very cool.
I have a suggestion that I am trying to implement: have the text in a cell wrap and the cell to increase in height - thus making the row's height higher as a result. Basically make the cell fit the given text.
I've not seen any list-view controls that can do that and it seems far more complicated to have variable height rows.
Any ideas?
Thanks,
Adrian
|
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A flexible WTL list control that supports Windows Vista style selection and cell editing.
| Type | Article |
| Licence | CPOL |
| First Posted | 10 Mar 2006 |
| Views | 297,311 |
| Bookmarked | 217 times |
|
|