Can anyone tell me how I can capture the repainting of the desktop?

I want to build a programme that fires and event when the desktop is shown, like when the last window is minimized.

cheers