Revision: 1021
http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1021&view=rev
Author: arnetheduck
Date: 2008-03-01 14:39:24 -0800 (Sat, 01 Mar 2008)
Log Message:
-----------
Simplify memory handling
Modified Paths:
--------------
dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp
Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp
===================================================================
--- dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp 2008-03-01 22:00:01 UTC (rev 1020)
+++ dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp 2008-03-01 22:39:24 UTC (rev 1021)
@@ -4,6 +4,8 @@
#include "../../include/smartwin/LibraryLoader.h"
+#include <boost/scoped_array.hpp>
+
namespace SmartWin {
bool WidgetListView::ComCtl6 = false;
@@ -408,28 +410,19 @@
logicalColumn = - 1;
HWND hHeader = reinterpret_cast< HWND >( ::SendMessage( hWnd, LVM_GETHEADER, 0, 0 ) );
int noItems = ::SendMessage( hHeader, HDM_GETITEMCOUNT, 0, 0 );
- int * myArrayOfCols = new int[noItems]; // TODO: Use boost::scoped_array or something...
+ boost::scoped_array<int> myArrayOfCols(new int[noItems]);
int xOffset = 0;
- try
+ ::SendMessage( hHeader, HDM_GETORDERARRAY, static_cast< WPARAM >( noItems ), reinterpret_cast< LPARAM >( myArrayOfCols.get() ) );
+ for ( int idx = 0; idx < noItems; ++idx )
{
- ::SendMessage( hHeader, HDM_GETORDERARRAY, static_cast< WPARAM >( noItems ), reinterpret_cast< LPARAM >( myArrayOfCols ) );
- for ( int idx = 0; idx < noItems; ++idx )
+ if ( myArrayOfCols[idx] == column )
{
- if ( myArrayOfCols[idx] == column )
- {
- logicalColumn = idx;
- break;
- }
- else
- xOffset += ListView_GetColumnWidth( hWnd, myArrayOfCols[idx] );
+ logicalColumn = idx;
+ break;
}
- delete [] myArrayOfCols;
+ else
+ xOffset += ListView_GetColumnWidth( hWnd, myArrayOfCols[idx] );
}
- catch ( ... )
- {
- delete [] myArrayOfCols;
- throw;
- }
return xOffset;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|