|
-
July 6th, 2010, 07:43 AM
#1
Edit box unlimited
Hi all, I'm using a edit box as an "append log" for my program.
I set it to "multiline" so I can write a new log every time. To write the log I append text using this code
Code:
CString strLine;
// Add CR/LF to text
strLine.Format(_T("\r\n%s"), pszText);
// Get the initial text length
int nLength = m_logedit.GetWindowTextLength();
// Put the selection at the end of text
m_logedit.SetSel(nLength, nLength);
// Replace the selection
m_logedit.ReplaceSel(strLine);
The problem is that the edit box is keeping about 3-4000 lines. After that the edit box won't log more text and keeps itself stucked in adding more text.
I thought two solutions:
1) Increasing its size to unlimited or something
2) Deleting previous text (like a ms-dos prompt does)
Can you help me in the simpliest way you can please?
-
July 6th, 2010, 07:52 AM
#2
Re: Edit box unlimited
The simples way is option 1 using SetTextLimit. The nicest way is option 2 because it eliminates the entire problem.
-
July 6th, 2010, 05:32 PM
#3
Re: Edit box unlimited
What about solution number two?
How do I make "runtime deleting previous contents" ?
-
July 6th, 2010, 05:51 PM
#4
Re: Edit box unlimited
You can also wire up a CString variable using the DDX mechanism and let MFC handle the data transfer for you.
Another approach is to use a List Control set to report mode. That way you can append a new line without having to overright the previous text. If you were really clever, you could make the List Control virtual and bind to a collection.
-
July 7th, 2010, 01:02 AM
#5
Re: Edit box unlimited
 Originally Posted by pm44xl22
What about solution number two?
How do I make "runtime deleting previous contents" ?
Simply use SetSel and ReplaceSel to delete a part of text at the beginning of your editbox.
-
July 7th, 2010, 04:02 AM
#6
Re: Edit box unlimited
Do you find that it may be useful sublassing the control?
-
July 7th, 2010, 04:34 AM
#7
Re: Edit box unlimited
You could also use a ListBox like A Logging ListBox Control
Victor Nijegorodov
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
|