Good point on the item leak.  I guess I just never ran into it since it's so 
infrequent.  I've never had a call to GetDC().  I guess the first time it 
happens I'll be all about finding a different way to do it ...
Hi Tom,
"Tom Serface" <tom@camaswood.com> ha scritto nel messaggio 
news:Or50bK5dKHA.6096@TK2MSFTNGP02.phx.gbl...
I think it's a good idea as well and I may change my code, but I don't 
think it's a huge difference if all you're looking for is the text extent 
to change the width of the list control.
The difference I was thinking of was exception safety of the code.
If GetDC is called, and then an exception is thrown before ReleaseDC call, 
the DC resource is leaked.
(Note that C++ exceptions can be thrown by several places, like STL 
containers or other code you may call before ReleaseDC.)
I think that RAII makes it easy to give a basic level of exception safety 
with a minimum effort by the programmer, this is why I like using it when 
possible (like Joe's CClientDC suggestion).
Of course, I've been known to use an occasional GetDlgItem() as well so I 
may just be old fashioned :o)
Me too... should we be sued for that? :)
G