Solved

CFrameWnd saving background as bitmap

Posted on 2004-03-23
4
470 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 250 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 250 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
font missing in acrobat 3 81
move a line in eclipse 3 111
How do I get Window Title of all opened process? 4 61
Text effect for logo 17 65
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses

751 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