Click here to Skip to main content
15,395,698 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to revert SetCheckBox style ? Pin
Richard MacCutchan29-Mar-11 5:36
mveRichard MacCutchan29-Mar-11 5:36 
GeneralRe: How to revert SetCheckBox style ? Pin
_Flaviu29-Mar-11 20:52
Member_Flaviu29-Mar-11 20:52 
QuestionCapture keyboard event in a dialog dll Pin
Y K Kishore Kumar28-Mar-11 20:27
MemberY K Kishore Kumar28-Mar-11 20:27 
AnswerRe: Capture keyboard event in a dialog dll Pin
Selvam R29-Mar-11 1:49
professionalSelvam R29-Mar-11 1:49 
QuestionIs any way to draw Background Image? Pin
002comp28-Mar-11 19:47
Member002comp28-Mar-11 19:47 
AnswerRe: Is any way to draw Background Image? Pin
Nitheesh George28-Mar-11 20:30
MemberNitheesh George28-Mar-11 20:30 
AnswerRe: Is any way to draw Background Image? Pin
Niklas L28-Mar-11 20:57
MemberNiklas L28-Mar-11 20:57 
AnswerRe: Is any way to draw Background Image? Pin
Hans Dietrich28-Mar-11 22:46
mentorHans Dietrich28-Mar-11 22:46 
You have three opportunities to reduce flicker:

1. Draw the image in the OnEraseBkgnd() handler and return TRUE.

2. Do other drawing in the OnPaint() handler. Use CMemDC to double buffer the dc. Since the entire background (I assume) is being covered with the image, there is no need to do a "fill" in OnPaint(); in fact, doing do would wipe out the image that was just drawn in OnEraseBkgnd().

3. In the OnSize() handler, tell Windows to defer re-positioning your controls until you are finished, You do this by using the DeferWindowPos() function (there are two other functions you will need, they are explained at that link).

The way Windows works, anything that obscures your window causes a WM_ERASEBKGND message to be sent to your window. This means that your window has to be redrawn when it is uncovered. Examples: moving another window on top of your window, or minimizing/restoring your window. So to answer your question, there is no way to "permanently" paint the background, because it is constantly being redrawn due to normal window operations.

It is also somewhat customary to do background stuff in OnEraseBkgnd() and foreground stuff in OnPaint(), although this is not a hard rule you have to follow; you can be sure that every WM_ERASEBKGND message will be followed by a WM_PAINT message.
Best wishes,
Hans


[Hans Dietrich Software]

GeneralRe: Is any way to draw Background Image? Pin
002comp29-Mar-11 2:32
Member002comp29-Mar-11 2:32 
QuestionError message running exe Pin
Cyclone_S28-Mar-11 13:55
MemberCyclone_S28-Mar-11 13:55 
AnswerRe: Error message running exe Pin
Luc Pattyn28-Mar-11 14:05
sitebuilderLuc Pattyn28-Mar-11 14:05 
GeneralRe: Error message running exe [modified] Pin
Cyclone_S28-Mar-11 14:13
MemberCyclone_S28-Mar-11 14:13 
AnswerRe: Error message running exe Pin
Luc Pattyn28-Mar-11 14:37
sitebuilderLuc Pattyn28-Mar-11 14:37 
AnswerRe: Error message running exe Pin
Albert Holguin28-Mar-11 15:36
professionalAlbert Holguin28-Mar-11 15:36 
AnswerRe: Error message running exe Pin
Hans Dietrich28-Mar-11 16:25
mentorHans Dietrich28-Mar-11 16:25 
GeneralRe: Error message running exe Pin
Albert Holguin28-Mar-11 17:45
professionalAlbert Holguin28-Mar-11 17:45 
AnswerRe: Error message running exe Pin
Nitheesh George28-Mar-11 20:27
MemberNitheesh George28-Mar-11 20:27 
GeneralRe: Error message running exe Pin
Cyclone_S29-Mar-11 14:02
MemberCyclone_S29-Mar-11 14:02 
AnswerRe: Error message running exe Pin
malaugh31-Mar-11 13:05
Membermalaugh31-Mar-11 13:05 
QuestionPreprocessor directives - resources Pin
bob1697228-Mar-11 5:36
Memberbob1697228-Mar-11 5:36 
AnswerRe: Preprocessor directives - resources Pin
Richard MacCutchan28-Mar-11 5:58
mveRichard MacCutchan28-Mar-11 5:58 
GeneralRe: Preprocessor directives - resources Pin
bob1697228-Mar-11 7:45
Memberbob1697228-Mar-11 7:45 
GeneralRe: Preprocessor directives - resources Pin
bob1697228-Mar-11 8:11
Memberbob1697228-Mar-11 8:11 
GeneralRe: Preprocessor directives - resources Pin
Richard MacCutchan28-Mar-11 9:06
mveRichard MacCutchan28-Mar-11 9:06 
GeneralRe: Preprocessor directives - resources Pin
bob1697228-Mar-11 17:02
Memberbob1697228-Mar-11 17:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.