|
-
Nov 6th, 2001, 09:50 AM
#1
Thread Starter
Lively Member
Editbox
I have created a window with an EditBox on it.
I want to create a function that appends the EditBox text with a line of text.
I currently have the following.
PHP Code:
void OutputDebug(char *text)
{
SendMessage(hwndEdit, WM_SETTEXT, 0,
(LPARAM) text);
}
The above code overwrites what is already in the EditBox.
How do I append it?
Thanks
-
Nov 6th, 2001, 10:37 AM
#2
PHP Code:
void OutputDebug(char *text)
{
char bigbuffer[1000];
SendMessage(hwndEdit, WM_GETTEXT, 1000,
(LPARAM) bigbuffer);
strcat(bigbuffer, text);
SendMessage(hwndEdit, WM_SETTEXT, 0,
(LPARAM) bigbuffer);
}
I think...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 6th, 2001, 10:38 AM
#3
Call SendMessage with WM_GETTEXT first to return the box's text. Concatenate the two strings, then call WM_SETTEXT to set the new string back into the box.
-
Nov 6th, 2001, 10:40 AM
#4
Woops! CB got there first!
IF you're writing some kind of logger or debug window, be aware that textboxes have a limit on text string length - 32767 chars including the null-terminator.
-
Nov 6th, 2001, 10:40 AM
#5
Thread Starter
Lively Member
Thanks - I did think of using a buffer but I thought there might be a more efficient way.
-
Nov 6th, 2001, 10:42 AM
#6
Thread Starter
Lively Member
Originally posted by jim mcnamara
IF you're writing some kind of logger or debug window, be aware that textboxes have a limit on text string length - 32767 chars including the null-terminator.
Thanks for this info
-
Nov 6th, 2001, 10:43 AM
#7
I don't think so. You can save space and sacrifice speed by using WM_GETTEXTLENGTH and strlen(text) to calculate the needed size of bigbuffer and dynamically allocate it.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 6th, 2001, 11:52 AM
#8
No. Missed communication.
I thought I was warning him about trying to put too long a string in the editbox, not how to allocate string memory. Issuing this warning was a result of concluding from the fact that his function was named OutputDebug, therefore, he would be streaming output to the box. I could be wrong.
And it really matters little.
-
Nov 6th, 2001, 11:54 AM
#9
Thanks - I did think of using a buffer but I thought there might be a more efficient way.
I hit reply just after this post...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|