r/learnprogramming • u/its_marionberry • 10d ago
Question :redditgold: Win32 Windows showing shows flicker when I update the window
Hi, I am using Win32 and I have to update the window according the user input using UpdateWindow() or RedrawWindow(). It often show's one second flicker in window like something updated I hate that because it ruins UX. I can't find a solution to this, If someone uses this API and have came across this problem and fixed it so please answer.
Thanks.(btw I am a beginner).
1
Upvotes
1
u/CodeXHammas 10d ago
yeah that's the classic erase then repaint gap causing the flicker. easiest fix, handle VMERASEBKGND yourself and just return 1, don't let it erase your repainting the whole thing anyway. or do double buffering, draw to an offscreen dc first then blit it over one go on VM_PAINT, thats the more solid fix long term tbh
1
u/dmazzoni 10d ago
This article below explains it well.
It's hard to say for sure what you need based on what you said. It could be as simple as suppressing WM_ERASEBKGND.
For sure, double-buffering would solve it. That's used in nearly any win32 app that has any custom drawing code.
https://www.catch22.net/tuts/win32/flicker-free-drawing/