Click here to Skip to main content
15,913,909 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: screen size Pin
Tomasz Sowinski3-Oct-02 6:50
Tomasz Sowinski3-Oct-02 6:50 
GeneralVisible Client Area question Pin
Steve The Plant3-Oct-02 6:12
Steve The Plant3-Oct-02 6:12 
GeneralRe: Visible Client Area question Pin
Tomasz Sowinski3-Oct-02 6:26
Tomasz Sowinski3-Oct-02 6:26 
GeneralRe: Visible Client Area question Pin
JT Anderson3-Oct-02 10:53
JT Anderson3-Oct-02 10:53 
QuestionHow do I use a CSortListCtrl in ListView? Pin
Pole3-Oct-02 5:56
Pole3-Oct-02 5:56 
Generalcrash on exit Pin
ns3-Oct-02 5:44
ns3-Oct-02 5:44 
GeneralRe: crash on exit Pin
Tomasz Sowinski3-Oct-02 5:49
Tomasz Sowinski3-Oct-02 5:49 
GeneralRe: crash on exit Pin
ns3-Oct-02 6:10
ns3-Oct-02 6:10 
memory cant be read.
(I hope theres enough info here for you to advise me...)
call stack points to:

void CSortListCtrl::FreeItemMemory( const int iItem )
{
	ItemData* pid = reinterpret_cast<ItemData*>( CListCtrl::GetItemData( iItem ) );

	LPTSTR* arrpsz = pid->arrpsz;

	for( int i = 0; i < m_iNumColumns; i++ )
		delete[] arrpsz[ i ];

	delete[] arrpsz;
	delete pid;

	VERIFY( CListCtrl::SetItemData( iItem, NULL ) );
}


which is from their AddItem (I want to make my own)
int CSortListCtrl::AddItem( LPCTSTR pszText, ... )
{
	const int iIndex = InsertItem( GetItemCount(), pszText );

	LPTSTR* arrpsz = new LPTSTR[ m_iNumColumns ];
	arrpsz[ 0 ] = new TCHAR[ lstrlen( pszText ) + 1 ];
	(void)lstrcpy( arrpsz[ 0 ], pszText );

 	va_list list;
	va_start( list, pszText );

	for( int iColumn = 1; iColumn < m_iNumColumns; iColumn++ )
	{
		pszText = va_arg( list, LPCTSTR );
		ASSERT_VALID_STRING( pszText );
		VERIFY( CListCtrl::SetItem( iIndex, iColumn, LVIF_TEXT, pszText, 0, 0, 0, 0 ) );

		arrpsz[ iColumn ] = new TCHAR[ lstrlen( pszText ) + 1 ];
		(void)lstrcpy( arrpsz[ iColumn ], pszText );
	}

	va_end( list );

	VERIFY( SetTextArray( iIndex, arrpsz ) );

	return iIndex;
}

Do I need this arrpsz stuff? Can I get rid of their freememory function? Its used by them in:

BOOL CSortListCtrl::DeleteItem( int iItem )
{
	FreeItemMemory( iItem );
	return CListCtrl::DeleteItem( iItem );
}

::DeleteAllItems();
}


I wont be needing to delete any items so I am paring down their class.

Appreciate your help,
ns
GeneralRe: crash on exit Pin
ns3-Oct-02 6:13
ns3-Oct-02 6:13 
GeneralRe: crash on exit Pin
Tomasz Sowinski3-Oct-02 6:11
Tomasz Sowinski3-Oct-02 6:11 
GeneralRe: crash on exit Pin
ns3-Oct-02 6:28
ns3-Oct-02 6:28 
GeneralRe: crash on exit Pin
Tomasz Sowinski3-Oct-02 6:35
Tomasz Sowinski3-Oct-02 6:35 
GeneralRe: crash on exit Pin
ns3-Oct-02 6:51
ns3-Oct-02 6:51 
GeneralRe: crash on exit Pin
Tomasz Sowinski3-Oct-02 6:54
Tomasz Sowinski3-Oct-02 6:54 
GeneralRe: crash on exit Pin
ns3-Oct-02 7:10
ns3-Oct-02 7:10 
GeneralRe: crash on exit Pin
Tomasz Sowinski3-Oct-02 7:19
Tomasz Sowinski3-Oct-02 7:19 
Generalits working!!!! Pin
ns3-Oct-02 7:37
ns3-Oct-02 7:37 
GeneralRe: its working!!!! Pin
Ravi Bhavnani3-Oct-02 7:57
professionalRavi Bhavnani3-Oct-02 7:57 
GeneralRe: its working!!!! Pin
ns3-Oct-02 8:08
ns3-Oct-02 8:08 
QuestionActiveX Question? Pin
Mr_Byte3-Oct-02 5:26
Mr_Byte3-Oct-02 5:26 
AnswerRe: ActiveX Question? Pin
Stephane Rodriguez.3-Oct-02 6:53
Stephane Rodriguez.3-Oct-02 6:53 
AnswerRe: ActiveX Question? Pin
Nitron3-Oct-02 7:14
Nitron3-Oct-02 7:14 
AnswerRe: ActiveX Question? Pin
l a u r e n3-Oct-02 7:15
l a u r e n3-Oct-02 7:15 
QuestionHow to display Internet mail Pin
hien_ng803-Oct-02 5:22
hien_ng803-Oct-02 5:22 
AnswerRe: How to display Internet mail Pin
jmkhael3-Oct-02 5:44
jmkhael3-Oct-02 5:44 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.