I am Drawing a image using GDI+ on OnPaint().And Its Flickering Whenever I resize Window.I tried all the ways to reduce Flicker but no Luck.
Actually,I am drawing it as background Image and I dont want to call it again and again.SO,Is there any way to draw background image using DC or some way so that OnPaint doesnt effect it and it remains there?
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.
collect more information, formulate an hypothesis, verify it, and when it seems correct, fix it.
IMO the two most likely categories of issues causing behavior somewhat like what you get, would be:
the system failing to locate or load a required piece of code, say a missing DLL. But then in my experience one gets a dialog box with a different message.
anything that could go wrong at the application level PLUS the app itself lacking proper error catching and reporting.
e.g. if one has try-catch constructs with an empty catch, then all clues get swallowed and all that is left is guessing at what the problem is.
I've seen this with missing DLLs or other components, such as configuration files (as Luc Pattyn stated), or there's a missing registry entry (or the registry entry doesn't contain the information expected).
Alternatively, you can compile the executable to use static libraries. Open Project->Properties, and select "use MFC in a static library" under General->Use of MFC, then go to Linker->General, go to "Delay Loaded DLLS" and uncheck the "inherit from parent" checkbox.
Last Visit: 31-Dec-99 18:00 Last Update: 9-Aug-22 9:37