Results 1 to 3 of 3

Thread: SDI Text

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    3

    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.
    Rick Mathers

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width