Click here to Skip to main content
15,920,828 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: C++ where to First? Pin
Hamid_RT26-Apr-07 21:43
Hamid_RT26-Apr-07 21:43 
QuestionVC++2005,interface Pin
lavy288326-Apr-07 4:56
lavy288326-Apr-07 4:56 
AnswerRe: VC++2005,interface Pin
toxcct26-Apr-07 7:00
toxcct26-Apr-07 7:00 
QuestionPass Array from VC++ Dll Pin
Samaya K.B.26-Apr-07 4:42
Samaya K.B.26-Apr-07 4:42 
AnswerRe: Pass Array from VC++ Dll Pin
CPallini26-Apr-07 5:22
mveCPallini26-Apr-07 5:22 
AnswerRe: Pass Array from VC++ Dll Pin
Paresh Chitte26-Apr-07 19:24
Paresh Chitte26-Apr-07 19:24 
GeneralRe: Pass Array from VC++ Dll Pin
Samaya K.B.26-Apr-07 19:54
Samaya K.B.26-Apr-07 19:54 
QuestionHelp to sort a vector of CObject! [modified] Pin
bosfan26-Apr-07 4:39
bosfan26-Apr-07 4:39 
Hello,
I use CSortListCtrl to show some data in a list, and all informations come from a lokal files,
i have a vector to store all datas for CSortListCtrl!
The property LVS_OWNERDATA is set!
Vector is for my own class derived from CObject, have some CStrings and integers!
Like this:
// CMyObject:public CObject to know what class typ is in vector
vector<CMyObject>VectorObject;
CMyObject myOb;
myOb.csName = "foo";
myOb.csIindex.Format("%d", iIndex);
// etc....
VectorObject.push_back(myOb);

When the user click on some column header, i like that the CSortListCtrl sorts all items and show.
Problem is that sometime i get a NULL pointer and my sort function crash!
// here is where i call my sortfunktion:
   if((GetStyle() & LVS_OWNERDATA)==0)  // this is my line, check if LVS_OWNERDATA is set, if not call VERIFY                                     
	VERIFY( CListCtrl::SortItems( CompareFunction, reinterpret_cast<DWORD>( this ) ) ); // original line
   else // here my changes
	{// if yes, go here, first printout only to see if all infos are here before sorting, yes!
		for_each(VectorResults.begin(), VectorResults.end(), print); // no errors?
		sort(VectorResults.begin(), VectorResults.end(),compare_vector);
		// show all sortet data, thi is ok to, no errors!?
		for_each(VectorResults.begin(), VectorResults.end(), print);
	}
// but here: :(
int compare_vector(const CMyObject& v1, const CMyObject& v2)
{
// here is problem: there is no problem so long i dont come to end!
// step by step i can see that v2.csIndex is NULL, is that the end of VectorResult???
	return lstrcmp(v1.csIndex, v2.csIndex); // 
}

In debug mode i can see that v2.csIndex is NULL, maybe im out of index, or what?
When i use for_each(VectorResults.begin(), VectorResults.end(), print); to see what is inside my
Vector, there is nothing strange, all infos are ok!
My question is how to use sort() ??
The idea to check if v2.csIndex is NULL dont work, because i go to CString compare funktion and
crash! Frown | :(

thanks for any help
termal



-- modified at 4:06 Friday 27th April, 2007
AnswerRe: Help to sort a vector of CObject! Pin
Arman S.26-Apr-07 5:28
Arman S.26-Apr-07 5:28 
GeneralRe: Help to sort a vector of CObject! Pin
bosfan27-Apr-07 1:47
bosfan27-Apr-07 1:47 
QuestionC++ text button save Pin
Anka_Ame26-Apr-07 3:56
Anka_Ame26-Apr-07 3:56 
AnswerRe: C++ text button save Pin
David Crow26-Apr-07 3:57
David Crow26-Apr-07 3:57 
QuestionRe: C++ text button save Pin
GuyM26-Apr-07 4:07
GuyM26-Apr-07 4:07 
QuestionRe: C++ text button save Pin
Rajesh R Subramanian26-Apr-07 8:05
professionalRajesh R Subramanian26-Apr-07 8:05 
AnswerRe: C++ text button save Pin
Hamid_RT26-Apr-07 21:45
Hamid_RT26-Apr-07 21:45 
QuestionCeSeekDatabaseEx() problem. [modified] Pin
mahendra.pardeshi26-Apr-07 3:43
mahendra.pardeshi26-Apr-07 3:43 
QuestionMFC DLL Static Const CString Not Resolved (LNK2001) Pin
Peter Saint26-Apr-07 2:57
Peter Saint26-Apr-07 2:57 
AnswerRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
KarstenK26-Apr-07 3:34
mveKarstenK26-Apr-07 3:34 
AnswerRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
Cedric Moonen26-Apr-07 3:42
Cedric Moonen26-Apr-07 3:42 
GeneralRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
Peter Saint26-Apr-07 3:45
Peter Saint26-Apr-07 3:45 
AnswerRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
GuyM26-Apr-07 3:51
GuyM26-Apr-07 3:51 
GeneralRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
Peter Saint26-Apr-07 4:23
Peter Saint26-Apr-07 4:23 
GeneralRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
GuyM26-Apr-07 4:30
GuyM26-Apr-07 4:30 
GeneralRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
Peter Saint26-Apr-07 5:17
Peter Saint26-Apr-07 5:17 
GeneralRe: MFC DLL Static Const CString Not Resolved (LNK2001) Pin
Cedric Moonen26-Apr-07 3:57
Cedric Moonen26-Apr-07 3:57 

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.