CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863
    Yah, I guess I should point out I ran that code in a WM_PAINT
    handler for a dialog to make sure it worked. (TDM's code actually
    had some small errors)

    Also the following includes are needed in the header for the
    templates and string
    #include <string>
    #include <sstream>
    #include <iostream>
    #include <iomanip>

    I kinda had the feeling CString would be used so I was a bit sloppy

    (I guess I just wanted to show how to do it right (with the standard) and definitely not with new char[].)
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  2. #17
    Join Date
    Jan 2004
    Location
    Earth
    Posts
    567
    Oh boy here we go again...I love it

    Originally quoted by gstercken
    Just in case you intend to copy the code as posted - watch out for that pitfall.
    In a previous post I clearly stated to use DC provided in the WM_PAINT handler if he is putting his drawing code in the WM_PAINT handler.

    In most cases doing painting in the WM_PAINT handler is the way to go because the window may only need to be repainted if it is resized or clipped by another window. You will have the benefits of only having the invalidated portions of the window to redrawn. I don't deny that....never have.

    Of course there are instances where doing all drawing in the WM_PAINT handler is not the most efficient and flicker free way to go.................

    TDM

  3. #18
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815
    Originally posted by TDM
    In most cases doing painting in the WM_PAINT handler is the way to go because the window may only need to be repainted if it is resized or clipped by another window. You will have the benefits of only having the invalidated portions of the window to redrawn. I don't deny that....never have.
    So we finally seem to agree on this...

    Look, most of the window-redrawing problems posted here can be tracked down to a wrong understanding of the repainting mechanism, and they are usually related to using CClientDC or GetDC() called from the wrong place - that's why I think it's important to propagate the 99,5% case (using CPaintDC in a WM_PAINT handler or the pDC passed in OnDraw) for any drawing code. A code sample using CClientDC is very likely to set people on the wrong track and lead to lots of problems in the future, that's why I commented on the code samples posted above.

Page 2 of 2 FirstFirst 12

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

Featured