I put this code in a project and compiled it. Do you ignore warnings, or are they turned off ? HDC hdcClock; COLORREF col; HDC hdc; char s[1024]; if(hdcClock) DeleteDC(hdcClock); hdcClock = NULL; You do not set hdcClock to NULL when you create it, and you never set it to anything else before trying to delete it. It's not NULL, and so it will try to delete it, but it won't point to anything valid. int nblink; RECT *prc; if(nblink == 0 || (nblink % 2)) col = RGB(255,255,0); nblink, same problem. RECT *prc; if(nblink == 0 || (nblink % 2)) col = RGB(255,255,0); else col = RGB(255,0,0); //if(col & 0x80000000) col = GetSysColor(col & 0x00ffffff); //SetBkMode(hdc, OPAQUE); //SetBkColor(hdc, col); hbr = CreateSolidBrush(col); FillRect(hdc, prc, hbr); same problem - prc. NEVER create a variable without initialising it's value. And goodness knows what half this code was trying to do, I assume you found an online sample and deleted half the code ? Also, you should step through the debugger first, before asking for help. If you do that, you may solve the problem and you'll at least be able to tell us the line that blows up, and the error you get ( actually, you should have been able to tell us the error anyhow ). Christian Graus - Microsoft MVP - C++