Click here to Skip to main content
15,902,893 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all!
I think maybe I find a bug of MFC. I have make a derive class of CStatic to draw a bitmap. In the main window, I create an object of the class, and implement a message-handler for WM_TIMER. Now I find that if I implement a message-handler for WM_PAINT in the derived class, the timer of main window stop working. If I commented the declaration of WM_PAINT's handler, the timer will be fine. I don't know the reason. Is this a bug of MFC? Or I need to call some other API to make the timer working correctly?
I hope someone would be kind to help me. Thx!
Posted
Comments
Sergey Alexandrovich Kryukov 11-Mar-13 23:58pm    
There are too many ways to screw up things. I don't know what way was yours :-).
In many cases, it's better to use thread instead of timer...
WM_PAINT is triggered if you call Invalidate, InvalidateRegion, InvalidateRectangle...
—SA
whiteclouds 12-Mar-13 23:16pm    
I'm just want to make a demo application. I am not plan to use some complex way to fix it. All I need is just to create a timer to update bitmap every some time. Now I find the correct way by myself. I can just call CWnd::OnPaint() in derived class to screw up it. Thank you!
Sergey Alexandrovich Kryukov 13-Mar-13 1:28am    
That's correct, but please understand that to help you to find a problem, we would need a code sample manifesting that problem. Complex or not, it's irrelevant, but it better should be very short, which is most usually possible, and comprehensive.
Good luck,
—SA

1 solution

Call CWnd::OnPaint() in the message-handler of WM_PAINT of the derived class. This small problem can be fixed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900