How would I make my program make text appear in a read-only edit box?
How would I make my program make text appear in a read-only edit box?
"If you tell the truth, you don't have to remember anything"
-Mark Twain
SetDlgItemText() will do that.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Thanx. Now, how would I put it in the next line? Like in a chatroom.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Uses something similiar to:
m_strString = "This is the First line \n\r This is the second";
// or it may be just a "\n", i forget which;
SetDlgItemText(IDC_EDIT1, m_strString);
Weeel, itss aboot tieme wee goo back too Canada, eeehy boyss.
Thanks again. Now, how would I make it write it in the edit box, then later, write in something else on the next line. Like a chatroom.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Hi,
Well in theory you would put your first line of text in, then get it into a varible then append that varible then display it in the control.
Now heres some code, im used to using SetWindowText() it works but you can use SetDlgItemText() if you want...
Code:char szNewBuffer[100]; //make the first line you want to display char szBuffer[100] = "This Is The First Line\r\n"; //now display it SetWindowText(hWndMyEdit, szBuffer); //now later in ur prog get the current text GetWindowText(hWndMyEdit, szNewBuffer, 100); //Now Append szNewBuffer onto the end of the first buffer //then display it strcat(szBuffer, szNewBuffer); SetWindowText(hWndMyEdit, szBuffer);
Thats just off the top of my head, but you should be able to fiddle around with that and apply it to your program.
Hope that helps.
TNT
TNT
You Can Stop Me, But You Cant Stop Us All
Um, how do I put this...
I don't get it.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Hi,
I will try to explain it a little simpler:
Say you have a chat prog as you said and say your edit box looks like this:
##############
# This Is Line 1 #
# #
# #
##############
So you have one line of text in it, "This is line 1". And if i understand you correctly and sorry if i dont, you want to add another line of text to it. So it looks like this:
##############
# This Is Line 1 #
# This Is Line 2 #
# #
##############
Ok so to do this first once youve made your edit box you put in the first line like this:
in the below code im asuming that you created your edit box using hWndEdit.
Code:char szLine1[100] = "This Is Line 1"; SetWindowText(hWndEdit, szLine1);
Ok so you now have an edit box with "This is line 1" in it.
Now at another point in your program you want to add another line to it, which i think is what your talking about.
Code:char szLine2[100] = "\r\nThis Is Line 2"; //now szLine2 needs to be added onto szLine1 then be displayed: strcat(szLine1, szLine2); //string.h //so now szLine1 contains: //ThisIsLine1 //ThisisLine2 //So now you have added another line we just need to update //the edit box: SetWindowText(hWndEdit, szLine2);
Once Done your edit box will have both lines of text in this proccess can be adapted to add multiple lines of text.
I think that is clearer than before, but sorry if i misunderstood your question.
Cheers
TNT
Thank you. Your explanation is perfect.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Look into HDC's.
If you are making a mainly chat app, you should use a Device Context to draw on. Rather than a large editbox. Will be easier in the long run.
Can use scrolling functions, different colours, fonts ect.
Use a Frame control and GetDC().
See
"Errors with resource bitmaps....HELP PLEASE"
for code to create a HDC.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
I would also question the wisdom of using an edit box control for displaying this kind of output. I think I would be inclined to use a list box.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Yes, you're right. How do you display info in a list box?
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Just do this:
SendMessage(handle_of_listbox, LB_ADDSTRING, (WPARAM)"String to add", (LPARAM)13);
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
>>SendMessage(handle_of_listbox, LB_ADDSTRING, (WPARAM)"String to add", (LPARAM)13);
I think it is
SendMessage(handle_of_listbox, LB_ADDSTRING, (WPARAM)0, (LPARAM)"String to add");
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill