Click here to Skip to main content
15,851,711 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: char arrays containing embedded NULL characters to be converted to BSTR Pin
CPallini15-Apr-08 2:00
mveCPallini15-Apr-08 2:00 
AnswerRe: char arrays containing embedded NULL characters to be converted to BSTR Pin
vsingh12315-Apr-08 2:09
vsingh12315-Apr-08 2:09 
GeneralRe: char arrays containing embedded NULL characters to be converted to BSTR Pin
CPallini15-Apr-08 2:36
mveCPallini15-Apr-08 2:36 
GeneralRe: char arrays containing embedded NULL characters to be converted to BSTR Pin
David Crow15-Apr-08 9:26
David Crow15-Apr-08 9:26 
QuestionRetreiving string pixel width and height Pin
Soumyadipta15-Apr-08 1:26
Soumyadipta15-Apr-08 1:26 
GeneralRe: Retreiving string pixel width and height Pin
Hamid_RT15-Apr-08 1:36
Hamid_RT15-Apr-08 1:36 
GeneralRe: Retreiving string pixel width and height Pin
Iain Clarke, Warrior Programmer15-Apr-08 6:56
Iain Clarke, Warrior Programmer15-Apr-08 6:56 
General[Resolved]::Sorting Ctime items in a list ctrl??? [modified] Pin
Priya_Sundar15-Apr-08 1:22
Priya_Sundar15-Apr-08 1:22 
I have a ListCtrl with a set of CTime:

09.45.25
10.44.22
07.49.25

I need to sort these..

also fyi.. i already have a array consisting of these values in m_arrTimes

Have used:

void CEntryDlg::OnColumnClickItemsList(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
	m_bSortNameAscSpItem = !m_bSortNameAscSpItem;<br />
<br />
	SortingItemsList();<br />
	<br />
	*pResult = 0;<br />
}<br />
<br />
void CEntryDlg::SortingItemsList()<br />
{<br />
	m_ctrlTimesList.SortItems(CEntryDlg::CompareSpItem, (DWORD)reinterpret_cast<DWORD>(this));<br />
<br />
	//To rearrange the serial number in asscending order<br />
	for(int i = 0; i < m_ctrlTimesList.GetItemCount(); i++)<br />
	{<br />
		m_ctrlTimesList.SetItemData(i, (LPARAM)i);<br />
	}<br />
}<br />
<br />
int CALLBACK CEntryDlg::CompareSpItem(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)<br />
{<br />
	CEntryDlg*pCurrentObj = (CEntryDlg*) lParamSort;<br />
<br />
	CString strTemp1 = pCurrentObj->m_ctrlTimesList.GetItemText(lParam1, 0); <br />
	CString strTemp2 = pCurrentObj->m_ctrlTimesList.GetItemText(lParam2, 0);  <br />
<br />
	CString strHr1,strMn1,strSc1;<br />
	strHr1 = strTemp1.Mid(0,2);<br />
	strMn1 = strTemp1.Mid(3,2);<br />
	strSc1 = strTemp1.Mid(6);<br />
<br />
	CString strHr2,strMn2,strSc2;<br />
	strHr2 = strTemp2.Mid(0,2);<br />
	strMn2 = strTemp2.Mid(3,2);<br />
	strSc2 = strTemp2.Mid(6);<br />
<br />
	CTime time1(2000,1,1, GetIntFromString(strHr1), GetIntFromString(strMn1),GetIntFromString(strSc1));<br />
	CTime time2(2000,1,1, GetIntFromString(strHr2), GetIntFromString(strMn2),GetIntFromString(strSc2));<br />
<br />
	if(pCurrentObj->m_bSortNameAscSpItem)<br />
	{<br />
		if(time1 == time2)<br />
			return 0;<br />
		else if(time1 < time2)<br />
			return -1;<br />
		else if (time1 > time2)<br />
			return 1;<br />
	}<br />
	else<br />
	{<br />
		if(time2 == time1)<br />
			return 0;<br />
		else if(time2 < time1)<br />
			return -1;<br />
		else if (time2 > time1)<br />
			return 1;<br />
	}<br />
<br />
	return 0;<br />
}<br />
<br />
CEntryDlg::GetIntFromString(CString str){<br />
		LPTSTR lpsz = new TCHAR[str.GetLength()+1];<br />
		int val=0;<br />
		if(lpsz !=NULL)<br />
		{<br />
			_tcscpy(lpsz, str);<br />
			val=::atoi(lpsz);<br />
			delete[] lpsz;<br />
		}<br />
		return(val);<br />
	}<br />
<br />


none of there seem to sort correctly..

Priya Sundar

modified on Wednesday, April 16, 2008 8:39 AM

GeneralRe: Sorting Ctime items in a list ctrl??? Pin
Cedric Moonen15-Apr-08 1:48
Cedric Moonen15-Apr-08 1:48 
GeneralRe: Sorting Ctime items in a list ctrl??? Pin
Priya_Sundar15-Apr-08 2:15
Priya_Sundar15-Apr-08 2:15 
GeneralRe: Sorting Ctime items in a list ctrl??? Pin
Cedric Moonen15-Apr-08 2:25
Cedric Moonen15-Apr-08 2:25 
GeneralRe: Sorting Ctime items in a list ctrl??? Pin
Priya_Sundar16-Apr-08 3:39
Priya_Sundar16-Apr-08 3:39 
GeneralRe: Sorting Ctime items in a list ctrl??? Pin
Cedric Moonen16-Apr-08 3:50
Cedric Moonen16-Apr-08 3:50 
GeneralThankyou. Pin
Priya_Sundar17-Apr-08 0:56
Priya_Sundar17-Apr-08 0:56 
GeneralAnd one more thing... Pin
Cedric Moonen15-Apr-08 2:36
Cedric Moonen15-Apr-08 2:36 
GeneralInserting a BMP image in the Picture control on the dialog window. Pin
Pruthvi.gm15-Apr-08 1:15
Pruthvi.gm15-Apr-08 1:15 
GeneralRe: Inserting a BMP image in the Picture control on the dialog window. Pin
Hamid_RT15-Apr-08 1:37
Hamid_RT15-Apr-08 1:37 
GeneralRe: Inserting a BMP image in the Picture control on the dialog window. Pin
Pruthvi.gm15-Apr-08 1:54
Pruthvi.gm15-Apr-08 1:54 
GeneralRe: Inserting a BMP image in the Picture control on the dialog window. Pin
Hamid_RT15-Apr-08 2:32
Hamid_RT15-Apr-08 2:32 
GeneralRe: Inserting a BMP image in the Picture control on the dialog window. Pin
Pruthvi.gm15-Apr-08 2:38
Pruthvi.gm15-Apr-08 2:38 
GeneralRe: Inserting a BMP image in the Picture control on the dialog window. Pin
Hamid_RT15-Apr-08 2:51
Hamid_RT15-Apr-08 2:51 
GeneralRe: Inserting a BMP image in the Picture control on the dialog window. Pin
Hamid_RT16-Apr-08 20:59
Hamid_RT16-Apr-08 20:59 
QuestionProblem using OnKeyDown in CDialog ???? Pin
TooShy2Talk15-Apr-08 1:13
TooShy2Talk15-Apr-08 1:13 
AnswerRe: Problem using OnKeyDown in CDialog ???? Pin
Hamid_RT15-Apr-08 1:40
Hamid_RT15-Apr-08 1:40 
AnswerRe: Problem using OnKeyDown in CDialog ???? Pin
TooShy2Talk15-Apr-08 1:59
TooShy2Talk15-Apr-08 1:59 

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.