Click here to Skip to main content
16,010,918 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to display a bitmap of 24 bits correctly?? Pin
Leesen22-Nov-01 16:48
Leesen22-Nov-01 16:48 
GeneralRe: How to display a bitmap of 24 bits correctly?? Pin
Christian Graus22-Nov-01 17:21
protectorChristian Graus22-Nov-01 17:21 
GeneralSorting the CStringArray Pin
Tili22-Nov-01 15:11
Tili22-Nov-01 15:11 
GeneralRe: Sorting the CStringArray Pin
Christian Graus22-Nov-01 16:42
protectorChristian Graus22-Nov-01 16:42 
GeneralRe: Sorting the CStringArray Pin
Jon Hulatt22-Nov-01 22:29
Jon Hulatt22-Nov-01 22:29 
GeneralRe: Sorting the CStringArray Pin
Tili23-Nov-01 7:23
Tili23-Nov-01 7:23 
GeneralRe: Sorting the CStringArray Pin
Christian Graus23-Nov-01 10:21
protectorChristian Graus23-Nov-01 10:21 
GeneralRe: Sorting the CStringArray Pin
Alvaro Mendez23-Nov-01 11:53
Alvaro Mendez23-Nov-01 11:53 
In case you're still interested, I have a nice global method that uses qsort to do it for you:

static int CompareStringsAscending(const void* pElement1, const void* pElement2)
{  
	return ((CString*)pElement1)->Compare(*(CString*)pElement2);
}
 
static int CompareStringsDescending(const void *pElement1, const void* pElement2)
{  
	return -(((CString*)pElement1)->Compare(*(CString*)pElement2));
}
 
static int CompareStringsAscendingNoCase(const void* pElement1, const void* pElement2)
{  
	return ((CString*)pElement1)->CompareNoCase(*(CString*)pElement2);
}
 
static int CompareStringsDescendingNoCase(const void *pElement1, const void* pElement2)
{  
	return -(((CString*)pElement1)->CompareNoCase(*(CString*)pElement2));
}
 
// Sorts the given array of CString objects according to the given set of flags.
void AMS_SortArray(CStringArray* pArray, bool bCaseSensitive = true, bool bAscending = true)
{
	ASSERT(pArray);
 
	int nElements = pArray->GetSize();  
	if (nElements <= 0)     
		return;
	
	int nSize = sizeof(CString*);  
	void* pFirstElement = (void*)&((*pArray)[0]);
	
	if (bCaseSensitive)
	{
		if (bAscending)
			qsort(pFirstElement, nElements, nSize, CompareStringsAscending);
		else
			qsort(pFirstElement, nElements, nSize, CompareStringsDescending);
	}
	else
	{
		if (bAscending)
			qsort(pFirstElement, nElements, nSize, CompareStringsAscendingNoCase);
		else
			qsort(pFirstElement, nElements, nSize, CompareStringsDescendingNoCase);
	}
}


AMS_SortArray is the one to use, but you should probably rename it to something more appropriate.

Regards,
Alvaro
GeneralCDialog Return Value Pin
Matt Newman22-Nov-01 11:53
Matt Newman22-Nov-01 11:53 
GeneralRe: CDialog Return Value Pin
Christian Graus22-Nov-01 12:11
protectorChristian Graus22-Nov-01 12:11 
GeneralRe: CDialog Return Value Pin
Matt Newman22-Nov-01 12:15
Matt Newman22-Nov-01 12:15 
GeneralComparing the contents of DC's Pin
Member 2362222-Nov-01 11:29
Member 2362222-Nov-01 11:29 
GeneralRe: Comparing the contents of DC's Pin
Christian Graus22-Nov-01 12:13
protectorChristian Graus22-Nov-01 12:13 
GeneralRe: Comparing the contents of DC's Pin
Member 2362222-Nov-01 18:23
Member 2362222-Nov-01 18:23 
GeneralRe: Comparing the contents of DC's Pin
Christian Graus22-Nov-01 19:25
protectorChristian Graus22-Nov-01 19:25 
GeneralDisabled 256-color toolbar buttons Pin
Erik Hammar22-Nov-01 11:06
Erik Hammar22-Nov-01 11:06 
GeneralRe: Disabled 256-color toolbar buttons Pin
Andrew Peace22-Nov-01 14:47
Andrew Peace22-Nov-01 14:47 
GeneralRe: Disabled 256-color toolbar buttons Pin
Rashid Thadha22-Nov-01 22:38
Rashid Thadha22-Nov-01 22:38 
GeneralCopying a HBITMAP to a different HBITMAP Pin
Chambers22-Nov-01 10:14
Chambers22-Nov-01 10:14 
GeneralRe: Copying a HBITMAP to a different HBITMAP Pin
Christian Graus22-Nov-01 10:39
protectorChristian Graus22-Nov-01 10:39 
GeneralRe: Copying a HBITMAP to a different HBITMAP Pin
Chambers22-Nov-01 10:58
Chambers22-Nov-01 10:58 
GeneralRe: Copying a HBITMAP to a different HBITMAP Pin
Christian Graus22-Nov-01 11:06
protectorChristian Graus22-Nov-01 11:06 
GeneralRe: Copying a HBITMAP to a different HBITMAP Pin
Chambers22-Nov-01 11:15
Chambers22-Nov-01 11:15 
GeneralRe: Copying a HBITMAP to a different HBITMAP Pin
Christian Graus22-Nov-01 11:20
protectorChristian Graus22-Nov-01 11:20 
GeneralAnalog to CArchive in STL for data transfer via sockets?... Pin
22-Nov-01 7:10
suss22-Nov-01 7:10 

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.