|
-
Sep 14th, 2001, 04:54 AM
#1
Thread Starter
New Member
SDI Text
I am trying to put text on a sdi program. here is an example of what I am doing:
CClientDC cdc(this);
CString mess;
mess.format("a message here");
cdc.textout(10,10,mess);
Now here is my problem, it prints it out to the screen, but if another window covers it, the text vanishes, and also if I want to put something else there I have to print out to that spot twice once with a really long empty string and then again with what I want there. Is there a way to keep the text there when another window covers it? And is it possible to have like a Clear Document command of some sort?
Thanks for the help in advance.
-
Sep 14th, 2001, 05:17 AM
#2
Monday Morning Lunatic
You should print the text during the OnPaint event of your window. If you don't have it, use ClassWizard to add it.
I think you can use something like InvalidateRect to clear it all, however that might flicker a bit.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 14th, 2001, 08:48 AM
#3
Since I think this is your main view, you would use OnDraw instead of OnPaint, there you already have a device context.
Also you don't have to use CString.format for simply assigning text, you can use the = operator instead (speed!!!). Format is for numbers you want to include in the string.
Example: to get "You have a score of 156" You would use:
string.format("You have a score of %i", iScore)
or something like this.
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
|