Hi,

I'm developing a hex editor control, and it displays the hex and raw
views into the document using a number of subcontrols. This is great,
but now I'm seeing a bug when I scroll my control very fast.

How it should look:
http://www.omega-prime.co.uk/files/invalidate-desired.png

How it does look:
http://www.omega-prime.co.uk/files/invalidate-bug.png

Since scrolling the control forces all the subcontrols to invalidate,
and they repaint separately, it can occur that they get out of sync on
screen (in this case, the selection is clearly different for each
control). This, however, would be OK if I could just get Windows to
redraw the least recently repainted control first (the flicker would
become unnoticable).

The problem is that this doesn't seem to be possible. The order in which
I issue Control.Invalidate calls is irrelevant! For example:

INVALIDATE TextAdapter
INVALIDATE SeparatorAdapter
INVALIDATE HexAdapter
INVALIDATE SeparatorAdapter
INVALIDATE AddressAdapter
PAINT AddressAdapter
PAINT SeparatorAdapter
PAINT HexAdapter
PAINT SeparatorAdapter
PAINT TextAdapter

This can lead to situations like this (when scrolling fast):

INVALIDATE AddressAdapter // Scrolled for the first time, invalidate
everything
INVALIDATE SeparatorAdapter
INVALIDATE HexAdapter
INVALIDATE SeparatorAdapter
INVALIDATE TextAdapter
PAINT AddressAdapter // Windows starts to paint...
INVALIDATE AddressAdapter // Scrolled again, only invalidate what needs
redrawing in a vain hope that repaints work as a queue
PAINT AddressAdapter // Windows starts to paint again, but not as a
queue, so e.g. AddressAdapter is always redrawn with top priority,
leading to the bug
PAINT SeparatorAdapter
PAINT HexAdapter
PAINT SeparatorAdapter
PAINT TextAdapter

So, is there a clean way to make invalidate events occur in order? Or is
there a better way to handle this graphical bug?

Thanks in advance!

Max