Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
alex.barylski28-Feb-02 16:26
alex.barylski28-Feb-02 16:26 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
Paul M Watt28-Feb-02 19:52
mentorPaul M Watt28-Feb-02 19:52 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
Paul M Watt28-Feb-02 10:53
mentorPaul M Watt28-Feb-02 10:53 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
alex.barylski28-Feb-02 12:29
alex.barylski28-Feb-02 12:29 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
Paul M Watt28-Feb-02 14:26
mentorPaul M Watt28-Feb-02 14:26 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
alex.barylski28-Feb-02 16:35
alex.barylski28-Feb-02 16:35 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
alex.barylski28-Feb-02 17:17
alex.barylski28-Feb-02 17:17 
GeneralRe: OnEraseBkgnd VS OnPaint Pin
Paul M Watt28-Feb-02 19:46
mentorPaul M Watt28-Feb-02 19:46 
I created a simple project that mimicks the code that you have shown me, but I did not find any place that it could be flickering, I may be missing a piece of your program that is causing the flickering.

This is how I tested it, and this is what I suggest you should do if you want to find out why it flickers, this should only take about 10 minutes:

Size DevStudio and your program so that they do not overlap, and they will not interfere with each other, this is so that you do not generate an extra paint message while you are debugging.

Next, find the OnPaint handler in your program, which I assume is actually in MFCs code base. You can either search for it, or set a breakpoint on your OnErase handler and follow the stack down to the OnPaint handler. Set a Breakpoint on the same line that initializes the paint DC in OnPaint, and at the first line of the OnErase handler.

Next get your program so that it paints the window like normal and then enable the breakpoint.

Perform the action that invalidates your window in the way that causes the flicker. Step into the CPaintDC contstructor, and then through the OnErase handler waiting for the function call that causes the window to be erased.

You only have to step through until the end of the OnErase handler, because when this function exits the CMemDC class goes out of scope and paints to the window. After this happens I do not see any otherway for your window to be updated.

One other thing that I noticed is that the CMemDC class looks like it is quite inefficient to use it in painting. every time a paint is required, it creates a new memDC, a new bitmap to select into the mem DC, it then deletes these objects also. You may save some cycles by caching these object in your own class, and blitting the bitmap at the end of the OnDraw event yourself.

IMO, I think that the paint code should be in the OnDraw Handler anyway.
GeneralSick and tired of VC++ IDE's $#!T Pin
Jason Hooper28-Feb-02 8:59
Jason Hooper28-Feb-02 8:59 
GeneralRe: Sick and tired of VC++ IDE's $#!T Pin
Carlos Antollini28-Feb-02 9:11
Carlos Antollini28-Feb-02 9:11 
GeneralFirst-chance exception error Pin
ed128-Feb-02 8:31
ed128-Feb-02 8:31 
GeneralRe: First-chance exception error Pin
Paul M Watt28-Feb-02 8:34
mentorPaul M Watt28-Feb-02 8:34 
GeneralRe: First-chance exception error Pin
Steen Krogsgaard28-Feb-02 9:44
Steen Krogsgaard28-Feb-02 9:44 
GeneralRestaurant Project Pin
28-Feb-02 8:21
suss28-Feb-02 8:21 
GeneralRe: Restaurant Project Pin
Carlos Antollini28-Feb-02 8:30
Carlos Antollini28-Feb-02 8:30 
GeneralRe: Restaurant Project Pin
Nemanja Trifunovic28-Feb-02 8:41
Nemanja Trifunovic28-Feb-02 8:41 
GeneralRe: Restaurant Project Pin
Christian Graus28-Feb-02 9:06
protectorChristian Graus28-Feb-02 9:06 
GeneralLoad gif, jpeg or tif image in VC++ Pin
28-Feb-02 7:29
suss28-Feb-02 7:29 
GeneralRe: Load gif, jpeg or tif image in VC++ Pin
Chris Losinger28-Feb-02 8:04
professionalChris Losinger28-Feb-02 8:04 
GeneralRe: Load gif, jpeg or tif image in VC++ Pin
Christian Graus28-Feb-02 9:25
protectorChristian Graus28-Feb-02 9:25 
GeneralRe: Load gif, jpeg or tif image in VC++ Pin
alex.barylski28-Feb-02 9:59
alex.barylski28-Feb-02 9:59 
GeneralRe: Load gif, jpeg or tif image in VC++ Pin
Christian Graus28-Feb-02 10:42
protectorChristian Graus28-Feb-02 10:42 
GeneralRe: Load gif, jpeg or tif image in VC++ Pin
Chris Losinger28-Feb-02 11:12
professionalChris Losinger28-Feb-02 11:12 
GeneralRe: Load gif, jpeg or tif image in VC++ Pin
Christian Graus28-Feb-02 11:21
protectorChristian Graus28-Feb-02 11:21 
GeneralRe: Load gif, jpeg or tif image in VC++ Pin
Chris Losinger28-Feb-02 12:07
professionalChris Losinger28-Feb-02 12:07 

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.