Thread: Automatically redrawing window contents

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Automatically redrawing window contents

    If, for example, I TextOut() something to a window outside WM_PAINT, do I ALWAYS have to manually redraw it if I want it to stay there? Ie, is there some option or API function that remembers what was in the window so that it redraws it automatically, or do I have to place the TextOut() call in WM_PAINT?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Unless you store it in an off-screen bitmap you'd have to manually update it each time. Even then, you'd still have to apply the bitmap. I think there are performance issues to take into consideration; WM_PAINT handling with its BeginPaint....EndPaint (which is necessary, ironically, even for gdiplus which 'supersedes and replaces' gdi) is the way to go.

    I'd be interested in reading other opinions about this, though.

    edit: apostrophe proliferation
    Last edited by Ken Fitlike; 08-23-2003 at 06:00 PM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    TextOut and DrawText are good for text that doesn't change too much (IMO). One thing I did for text that was bound to change was to create a readonly edit box, and changed the background color. Then you have to get the code to put text into the edit box.

    I say this as a novice to window's programming however

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Thanks, that's all I needed to know.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>Unless you store it in an off-screen bitmap

    This is the best way.

    For complex apps have a back buffer to swap with as drawing can take some time.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  3. Adding colour & bmps to a Win 32 Window??
    By carey_sizer in forum Windows Programming
    Replies: 4
    Last Post: 09-04-2004, 05:55 PM
  4. Problem with creating new window, from another window
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-11-2004, 02:10 PM
  5. Invoking MSWord
    By Donn in forum C Programming
    Replies: 21
    Last Post: 09-08-2001, 04:08 PM