Click here to Skip to main content
15,938,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to clear static text data when data fills the static text in display in wrap or no wrap properties are used in mfc?

suppose there is a text say
1 2 3 4 5 and

when next 6 comes it should erase 1 and the data in text should be

2 3 4 5 6

when next 7comes it should erase 2 and the data in text should be

3 4 5 6 7

And also I want to change the color of recently entered character say 6 then when 7 comes 6 comes to normal color and 7 should change the color
Updated 8-Mar-12 16:19pm

Static or non-static — it's irrelevant to the question (if you understand what is static correctly). "MFC" probably means using the class CString, please see:[^].

The function you can use if CString::Delete(int nIndex, int nCount = 1).

Share this answer
chaiein 8-Mar-12 23:45pm    
Delete works:) Thanks again:) Now I want to change the color of recently entered character say 6 then when 7 comes 6 comes to normal color and 7 should change the color.
Sergey Alexandrovich Kryukov 9-Mar-12 0:04am    
Sure, you are welcome.

The question about color is unrelated to the strings. A string has no color. There is no such thing as a color of a string or a character. You could have a number of different instances of some controls, each instance of its own color. Alternatively, use one rich edit control CRichEditCtrl and format selections of text with different colors.

chaiein 9-Mar-12 0:58am    
can't we use static text instead of CRichEditCtrl control ?
Sergey Alexandrovich Kryukov 9-Mar-12 1:25am    
Yes, with only one color. Text is text, it cannot have colors. A text control can, but only one (background and foreground). Just look at the property of each control and you will see. I can only repeat my comment above.
chaiein 9-Mar-12 1:33am    
ok I understand. How to change the complete text color in static text control suppose only when i click a button.
if you want to change the colors use RichEdit control, in which you can specify different colors for chracaters. see [^]
Share this answer
chaiein 9-Mar-12 1:00am    
can't i use static text control instead for color ?
jk chan 9-Mar-12 4:59am    
static text not have such feature, otherway is to draw characters by yourself using functions like DrawText or TextOut, and setting colors SetTextColor.. In this case you need to handle painting of your control yourself. This is also easy.
d++; //here count the number of displayed characters
if(d==28)// my static text control 28 characters fills the length of its display
m_Keys.dischords.Empty();//when it reaches limit empty the text
d=0;//start again from first count
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900