Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CFrameWnd saving background as bitmap

Posted on 2004-03-23
4
Medium Priority
?
477 Views
Last Modified: 2013-12-03
Hi,

I have subclassed a CFrameWnd, overridden OnPaint and in there I BitBlt some stuff to the window. I then save what i have done through a bitmap to a CDC object.  I then continuing painting as i do not want to include this extra stuff in the DC.  I only do this once ie

OnPaint event{
  draw();
  if(!done) {
    savebackground();
    done = true;
  }  
  drawOtherStuff();
}

This appears to work most of the time, but occasionally it is as if the wrong thing gets saved to the DC or I am saving before the frame is painted and i get a blank, white background with no images on it.

I am guessing what I am doing is not guaranteed to save the background, so how do I ensure what I am saving is what I want?

thanks for any help clarifying the situation.
0
Comment
Question by:jasoncpp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:jasoncpp
ID: 10664161
Just to add, it is saving the blank background, not the stuff after any blitting, but the regular form's surface.   I noticed that when the frame loads slowly this is what it captures, as if the first draw instructions are not written to the frame in time for the save instructions so it gets a blank form.
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 1000 total points
ID: 10664342
one suggession... create a memory dc and draw all the stuffs in that DC, and copy that to screen DC on OnPaint
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 1000 total points
ID: 10664984
You also need to cope with window being resized.

Have a member variable in class of type bitmap.
When background not prepared create a memory dc, put bitmap into that, draw the bitmap.  Now bitmap prepared.
In paint dc just BitBlt this bitmap to your background.

A tip.  Provide handler for WM_ERASEBACKGROUND and in the function DO NOTHING AND RETURN TRUE.  This will stop a lot of flicker
0
 

Author Comment

by:jasoncpp
ID: 10668974
Thank you, I found both comments helpful.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question