August 11th, 2010, 10:56 PM
CreatePen() return null in timerproc() after running for about 100s
Thank you for your attention, I met this problem in my timerproc function.
I need to change the color of the pen according to a changing value, so I need to createpen in this timerproc. After running normally for about 100s, pen.createpen() begins to return 0. If I step over in the debug mode, it enters wincore.cpp when it step over the pDC->SelectObject() function.(Is it an exception?)
The GDI resource didn't increase when I ran the program even when it got stucked at about 100s(the timerproc receive a WM_TIMER message every 30ms), neither did the CPU or the Memory. The GetLastError() function returns 0 right after the createpen() function. And the program cannot step over pen.SelectObject(), if there is a breakpoint before the SelectObject() function, it goes there when I try to step over SelectObject(); if there isn't, it enters the wincore.cpp as I said above.
I paste my code below,
pen.CreatePen(...) //CreatePenIndirect() returns 0 here too
old_pen=pDC->SelectObject(&pen);//cannot step over here
Looking forward to your help, sincerely!
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!