Click here to Skip to main content
15,888,270 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
Justin Tay25-Jul-06 20:43
Justin Tay25-Jul-06 20:43 
AnswerRe: mfc drawing philosophy question - when is the correct time to draw? [modified] Pin
charlieg26-Jul-06 1:13
charlieg26-Jul-06 1:13 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
Justin Tay26-Jul-06 2:22
Justin Tay26-Jul-06 2:22 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
charlieg26-Jul-06 3:39
charlieg26-Jul-06 3:39 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
charlieg26-Jul-06 4:02
charlieg26-Jul-06 4:02 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
Justin Tay26-Jul-06 4:19
Justin Tay26-Jul-06 4:19 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
charlieg26-Jul-06 4:24
charlieg26-Jul-06 4:24 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
Justin Tay26-Jul-06 4:13
Justin Tay26-Jul-06 4:13 
charlieg wrote:
What I'm trying to understand is the initial dialog/window creation sequence and the ramifications on drawing.


You could try using a spy application like this[^] to look at the kind of messages that windows generates for your application.

charlieg wrote:
theory is that when a dialog/window is created, everything is invalid


Yes when your window is created everything is invalid.

charlieg wrote:
WM_ERASEBKGND - with a couple of very unique situations, I never handle this.


When windows sees that there is an invalid region (and there are no more messages on the queue) it will generate 2 messages, WM_ERASEBKGND and then WM_PAINT. Windows paints the entire invalid client area with the background brush for you if you choose not to explicitly handle WM_ERASEBKGND.

Windows flicker for 2 reasons. One is when it takes too long to draw and you're drawing directly to the screen, then you can see windows drawing your window piece by piece. The other is when the window gets invalidated too quickly, ie, you keep having a lot of WM_ERASEBKGND and WM_PAINT messages in succession. The default window procedure (if WM_ERASEBKGND isn't handled and you don't return a non-zero value) will paint the entire client area with the background for you. This is usually undesirable if you are trying to eliminate flicker as you first have a white screen, then what you painted, then white again, etc, causing flicker.

charlieg wrote:
Usually, I do not do an invalidate operation, electing to draw out of the OnTimer handler


The problem with this is when your window gets obscured and uncovered by another window. In which case windows will generate a WM_ERASEBKGND and WM_PAINT message. If WM_ERASEBKGND is not handled, the invalid area is painted with the background brush for you. If WM_PAINT doesn't do anything, then you just have the background. If you handled WM_ERASEBKGND and elected not to do anything and WM_PAINT isn't doing anything, then you are left with whatever bits happen to be there on the invalid area of your window. Of course if your timer is fast and you keep painting to the screen, it's unlikely that you'd really notice anything amiss.
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
charlieg26-Jul-06 4:59
charlieg26-Jul-06 4:59 
GeneralRe: mfc drawing philosophy question - when is the correct time to draw? Pin
Justin Tay26-Jul-06 5:34
Justin Tay26-Jul-06 5:34 
QuestionConvert CString to Unsigned short & Vice Versa Pin
JBAK_CP25-Jul-06 13:00
JBAK_CP25-Jul-06 13:00 
AnswerRe: Convert CString to Unsigned short &Vice Versa Pin
Justin Tay25-Jul-06 13:15
Justin Tay25-Jul-06 13:15 
QuestionBitmap associated with a static control Pin
cphawk25-Jul-06 12:09
cphawk25-Jul-06 12:09 
AnswerRe: Bitmap associated with a static control Pin
sudeesh26-Jul-06 2:40
sudeesh26-Jul-06 2:40 
QuestionCan't find files Pin
jimNLX25-Jul-06 11:52
jimNLX25-Jul-06 11:52 
AnswerRe: Can't find files Pin
Justin Tay25-Jul-06 13:22
Justin Tay25-Jul-06 13:22 
QuestionTabCtrlSSL tab control code Pin
BuckBrown25-Jul-06 10:18
BuckBrown25-Jul-06 10:18 
QuestionPrecompiled header error Pin
Jay0325-Jul-06 8:41
Jay0325-Jul-06 8:41 
AnswerRe: Precompiled header error Pin
Zac Howland25-Jul-06 8:53
Zac Howland25-Jul-06 8:53 
AnswerRe: Precompiled header error Pin
Michael Dunn25-Jul-06 8:56
sitebuilderMichael Dunn25-Jul-06 8:56 
QuestionRe: Precompiled header error [modified] Pin
Jay0325-Jul-06 9:58
Jay0325-Jul-06 9:58 
AnswerRe: Precompiled header error Pin
Zac Howland25-Jul-06 10:02
Zac Howland25-Jul-06 10:02 
GeneralRe: Precompiled header error Pin
Jay0325-Jul-06 10:15
Jay0325-Jul-06 10:15 
QuestionDirectShow filter problem Pin
DobosCake25-Jul-06 5:38
DobosCake25-Jul-06 5:38 
AnswerRe: DirectShow filter problem Pin
cje26-Jul-06 10:53
cje26-Jul-06 10:53 

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.