Redisplay of a window

Hi
I am working with GUI programming without using Phab.
My window works fine the first time I click a button to launch it.
But when I close it and repress the button to launch it.
The window doesnt displays properly.
It takes some background from the previous window which has the button on it.
And the display is not proper.doesnt closes properly after that.

Thanks

Not enough information, if you could post some code.