Link to home
Start Free TrialLog in
Avatar of sector
sector

asked on

How to stop a CWnd flickers & tramble

I have created a control with 4 buttons & with drawing some
lines in the OnPaint. when pressing one of the buttons causes other buttons to move with the CWnd::MoveWindow().
The buttons move as expected but the control flickers and
trumbles while moving the button.
why is that and how can i correct it ???
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is because when the button is moved, the parent window gets a WM_PAINT message, which causes the parent window to redraw, it clears the buttons, then the buttons are put back. Thus, you see it flicker.
The window flickering because it is slow to draw graph in Windows. Windows do not have direct access to the memory cells corresponding to the onscreen pixels, it processes the drawing statement through many layers of sofware. This process takes a long time time and results in the flickering.
Microsoft release the WinG library to help developing fast graphics operations with windows. It can be realized through a WinG OLE control.
Slow drawing does not cause flickering. Filickering is caused by drawing it, clearing it and drawing it again.

WinG is obsolete. Use DirectX if you want fast graphics operations.