Thanks for your ideas.
Quote:
Originally Posted by
srelu
1. You forget to deselect the hBitmap from the dc at the end. That will create problems for sure.
Forget? No. What is "deselect"? There is no other bitmap existing to "replace" the one containing the window's image. Are you saying I should have a "null" bitmap handle to replace hBm when painting is done?
Quote:
2. The fact that WM_PAINT is sent doesn't mean necessarily that it will repaint the whole window. It will repaint only the invalid region of the window. You don't need to bother about that, the OS will properly invalidate any area in need to be repainted.
Yes, I know this.
Quote:
a. Are you sure the right bitmap is selected all the time in the sdc ?
b. Is the bitmap containing the right image ?
c. Are coordinates and sizes properly calculated ?
d. Is your bitmap large enough to cover the whole window ?
a) Yes, there is only one.
b) Absolutely.
c) Yes.
d) Yes.
Quote:
4. Never call Invalidate from the inside of the WM_PAINT message handler.
I have never done this before, but out of desperation, I had to try different things. This seemed to eliminate the ghost trails (in trade for intermittent flickering).
Quote:
5. Are you sure that you comply with all the requirements to deal with graphic functions ?
AFAIK.
Quote:
- Each SelectObject must have a pair that deselects that object when no longer needed
I have never heard if this in 15 years of GDI programming. I wonder why not.
Quote:
- Each bitmap creation function must have a DeleteObject pair to delete it when no longer needed
- Each dc created must be deleted/released when no longer necessary.
DC function pairs:
BeginPaint with EndPaint
GetDC with ReleaseDC
CreateCompatibleDC with DeleteDC
Understood. I always do this. I typically use NuMega Bounds Checker to tell me if I am missing any DeleteXX calls.
Quote:
When deleting a dc, none of the objects created by you must be left selected in it. (That's what you did wrong here. And probably there are more in the code you didn't post.)
Again, I have never heard of this. Do you have a link to info that says this is so?
Quote:
Failure to comply with all these requirements will lead to serious problems. Just creating graphic objects and not disposing them properly will fill all the GDI memory with useles objects. You will run out of the GDI memory with unpredictable results. Anyway here's a prediction: subsequently all graphic operations will fail, you window will start displaying graphics "borrowed" from the overlapping windows.
I have never had any GDI problems in many years of intermittent Windows programming. This is the first instance of "repaint failure", and it is curious that it happens only on XT and sometimes on Vista, but never on W2K. I do not have Win7 to test on.
I will try some of your ideas, only because I have nothing to lose. If they magically fix my problem, then I will return here to eat crow.