Skip to main content
gamedev.net
🔒 Locked

Another Windows Question

Started by Drizzt DoUrden 6 replies 1.4k views
Original Post
Drizzt DoUrden
Drizzt DoUrden
When working wit edit boxes, let's say, you have two: one edit box is a log of everything the user types and executes, the other is a field in which you enter a command to be sent to the log. You have a dialog box holding these two edit boxes and a piece of code looking like this:
    
case IDEXEC:												             
	MessageBox(hwnd, "Executed!", "Click Ok to Continue...", MB_OK);
					
	char buff[64];
	int length = 64;
	GetDlgItemText(hwnd, IDC_COMMAND, buff, length);
	SetDlgItemText(hwnd, IDC_LOG, buff);
					
	return TRUE;
  
Now, this code is great to change the text in the log to what is in the command edit box. But I want it to create a new line and add it to what's in the log every time they execute something. I looked on MSDN and winprog.org and I couldn't really find anything to help me figure out how to make it this way. Any help would be greatly appreciated, thanks in advance. [edited by - Drizzt DoUrden on November 29, 2002 2:02:26 AM]
------------------------------Put THAT in your smoke and pipe it
Drizzt DoUrden
Drizzt DoUrden
That sounds basically exactly what I had planned to do, but I don''t quite know how to do it ^_^.
------------------------------Put THAT in your smoke and pipe it
Evil Bill
Evil Bill
Why not use a list box insterad of an edit box for the log? Then you just need to call AddString().

Edit:
To do what you propose:

  
int nLen1 = SendMessage(GetDlgItem(hwnd,IDC_LOG),WM_GETTEXTLENGTH,0,0);
int nLen2 = SendMessage(GetDlgItem(hwnd,IDC_COMMAND),WM_GETTEXTLENGTH,0,0);
char* pBuff = new char[nLen1+nLen2+1]; // +1 for the '\n' (Add more if you want)

GetDlgItemText(hwnd,IDC_LOG,pBuff,nLen1);
pBuff[nLen1] = '\n';
GetDlgItemText(hwnd,IDC_COMMAND,pBuff+nLen1+1,nLen2);
SetDlgItemText(hwnd,IDC_LOG,pBuff);
delete[] pBuff;


HTH



[edited by - Evil Bill on November 29, 2002 11:01:38 AM]
Member of the Unban Mindwipe Society (UMWS)
Drizzt DoUrden
Drizzt DoUrden
Heh, I''m not familiar with list boxes at all and after searching for some help, I still found nothing useful.

I understand how the proccess would work but the code you posted doesn''t actually add the text in IDC_COMMAND to the list box IDC_LOG, at least when I execute it in my program. Is there something I am missing here, or something I was supposed to add?

Thanks for the help so far ^_^
------------------------------Put THAT in your smoke and pipe it
Evil Bill
Evil Bill
Drizzt DoUrden: That code is for appending text to an Edit box, not a list box. If it were me, i''d use a list box, and just do LB_ADDSTRING (i think thats the right message) to add a string to the listbox.

Member of the Unban Mindwipe Society (UMWS)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.