i don't think invalidating will help since it appears you are drawing directly on the bitmap you created. One possible solution is drawing the squares instead in the paint event on the window. Then a simple "if squares = visible then" would solve your problem.