Strange palette and delay behavious with page-flipping

I tried an example when there is an 8-bit framebuffer. I set the palette,
fill the buffer with a color, and wait for 3 seconds.
Then change the color I used for clearing the buffer in the palette, and
waith for other 3 seconds, before exiting.
When I’m in window mode, or in fullscreen mode with software surface, there
is no problem (after changing the color, it is immediately changed in the
screen, then the app waits for 3 seconds, then exeits.).
In fullscreen mode with page flipping, anyway, after changing the color, the
image is still the same, then it waits for the last 3 seconds, and just a
moment before exiting the screen changes color.

I tried under Windows 2000 with Matrox G400 and DirectX8 (didn’t try under
Linux and Windows ME yet).