GetDC and drawing problem with WS_EX_COMPOSITED
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: GetDC and drawing problem with WS_EX_COMPOSITED

  1. #1
    Join Date
    Aug 2009
    Location
    Zhengzhou,China
    Posts
    3

    Question GetDC and drawing problem with WS_EX_COMPOSITED

    I have a window and it has a WS_EX_COMPOSITED extended style, I handle the WM_ERASEBKGND Notification and wm_paint message, everything seems right, but when I call GetDC&ReleaseDC in some place, and do some drawing with GDI functions, I simply can't draw it on the window, during I debug the program, I found that after my drawing calls, the window will handle the wm_erasebkgnd and wm_paint messages, and the action in erasebkgnd overlap the drawing, and this is why the drawing seems doesn't work,

    and after I remove the ws_ex_composited style, there is no more wm_paint message ,and GetDC could work,

    now I just wonder if there is a ws_ex_composited style, then you can't drawing outside erasebkgnd handler and wm_paint handler, am I right?

    Is there anyone who have meet the similar problem?

    Regards.


    David

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,878

    Re: GetDC and drawing problem with WS_EX_COMPOSITED

    Drawing outside WM_PAINT and WM_ERASEBKGND will indeed not work right for a WS_EX_COMPOSITED style window.

    The reason why should be obvious. Part of the composition consists of creating an off-screen image for the double buffer then iterate down to top through the windows to have each window in the area paint itself (accounting for (semi)transparancy) and having the double buffer blit in one go to the actual screen. This double buffering isn't active when you're just painting something "somewhere" in your code.

    You can make it work (sort of), but as soon as you go on vista with desktop composition enabled it'll break down because now you're not actually painting to the window canvas but to the desktop directly. If you really really NEED to paint outside of those 2 functions, and need the features of composition your safest bet is making a single top level window and handling all composition yourself, but that means you can't use standard Window controls.

  3. #3
    Join Date
    Aug 2009
    Location
    Zhengzhou,China
    Posts
    3

    Re: GetDC and drawing problem with WS_EX_COMPOSITED

    Thank you!

    Now I think I can handle all the painting in WM_PAINT and WM_ERASEBKGND message handlers, and I am going to use some boolean value to indicate the drawing actions in those two message handlers.

    I didn't find too much useful information in MSDN, and thanks again for your replying:-)
    Last edited by xfpl; September 1st, 2009 at 10:45 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center