AdventGamer 0 Newbie Poster

ok well i'm having issues sending a char array to a listbox. To do a little explanation on the code itself... The point of this part is to take a hexidecimal string and convert it to a alphabetical string (this part works and has been tested in a console application). I then have a vShowText function that i used to add items into my listbox. It has worked thus far and i have even added char arrays to the listbox using it. In this particular case i can't seem to make the char array show up into the listbox, it just inserts a line of D like characters. This is sorta difficult to explain so i hope i'm doing a good enough job of it. I will post code to help explain more below.

here is my vShowText function that is being used to insert text into the listbox.

void vShowText(HWND	hChildHandle, char *szText)
{
	int Line;
	
	// add string to the listbox
	SendMessage(hChildHandle,LB_ADDSTRING,0,(LPARAM)szText);
	
	// determine number of items in listbox
	Line = SendMessage(hChildHandle,LB_GETCOUNT,0,0);
	
	// flag last item as the selected item, to scroll listbox down
	SendMessage(hChildHandle,LB_SETCURSEL,Line-1,0);
	
	// unflag all items to eliminate negative highlite
	SendMessage(hChildHandle,LB_SETCURSEL,-1,0);
}

below is where my problem is. This is the actual code to change the hex string into a alphabetical one. When the loop is done going through the hex string, ptrBuffer is reset to point to the first element in the char buffer[100] array. Then vShowText is called to display the contents of the buffer array into the listbox. I have also tried to just do vShowText(hlistbox, buffer). Both of these methods does the same thing and inserts a line of D like characters into the listbox... so it looks something like this DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD. Only they aren't actual D's.

also i am able to just make a char array and then later call vShowText with the array as a parameter and it displays in the listbox fine. Example is below.

//create a char array
char myArray[100] = "Hello World!";

//later in the program
vShowText(hlistbox, myArray);


the actual code snipplet:

case MENU_FILE_TRANS:
{
	char *ptrBuffer = &buffer[0];

	for (int i = 0; i < RecvBytes; i+=2)
	{
		int firstvalue = RecvData[i] - '0';
		int secondvalue;
		//if RecvData[i+1] is a letter convert it to integer, otherwise use it.
			switch(RecvData[i+1])
			{
			case 'A':
			{
				secondvalue = 10;
                 
			}break;
			case 'B':
			{
				secondvalue = 11;
                 
			}break;
			case 'C':
			{
				secondvalue = 12;
                 
			}break;
			case 'D':
			{
				secondvalue = 13;
                 
			}break;
			case 'E':
			{
				secondvalue = 14;
                 
			}break;
			case 'F':
			{
				secondvalue = 15;
                 
			}break;
			default:
				secondvalue = RecvData[i+1] - '0';
			break;
		}
         
         
		//convert the two values into decimal form
		newval =  16 * firstvalue + secondvalue;
         
		//change newval into a character
		*ptrBuffer = char(newval);

		//SendMessage(hlistbox,LB_ADDSTRING,0,(LPARAM)ptrBuffer);
		ptrBuffer++;

		//vShowText(hlistbox, ptrBuffer);
	}

	ptrBuffer = &buffer[0];


	vShowText(hlistbox, ptrBuffer);
	

}break;