Ehem... Three seconds after sending the message I noticed that DeleteObject(hbrush); I deleted the line and now it works fine. Thanks.