I thought about it for a long time. I didn't think of a good name. I 'd like to name it for the moment.
Native programming, it seems that there is no good choice except painting. in fact, I chose static controls instead of painting. I don't think there is any essential difference between painting on other controls and static controls. (I just think static controls are simple enough and can achieve my goal)
OK. Let's talk about the painting first. The only thing that needs to be paid attention to is the problem of the flash screen. The dual buffer is used to prevent the flash screen. How can this problem be solved?
1. Prevent background painting. I need to draw the background by myself.
2. Create a memdc. All images are completed on memdc.
3. Copy the painted items to DC (using bitblt)
At this point, the most essential content has been introduced, and the following is just a sample. There is nothing in this sample (SWEAT )...
// Register the erasebkgnd and paint begin_message_map (mystatic, cstatic) values () on_wm_paint () end_message_map () // header file class mystatic: Public cstatic {declare_dynamic (mystatic) public: mystatic (); Virtual ~ Mystatic (); protected: afx_msg bool onerasebkgnd (CDC * PDC) {return true;} afx_msg void onpaint (); declare_message_map () PRIVATE: void paintonmemdc (crect client, CDC * pmemdc) ;}; // implement implement_dynamic (mystatic, cstatic) mystatic: mystatic () {} mystatic ::~ Mystatic () {} void mystatic: onpaint () {cpaintdc DC (this); cpaintdc * PDC = & DC; crect client; getclientrect (& client); CDC m_memdc; if (! M_memdc.m_hdc) {cbitmap m_memmap; m_memdc.createcompatibledc (PDC); m_memmap.createcompatiblebitmap (PDC, client. width (), client. height (); m_memdc.selectobject (& m_memmap); m_memmap.deleteobject (); m_memdc.setbkmode (transparent);} paintonmemdc (client, & m_memdc); PDC-> setbkmode (transparent ); PDC-> bitblt (client. left, client. top, client. width (), client. height (), & m_memdc, 0, 0, srccopy); m_memdc.deletedc ();}
Draw here:
Void mystatic: paintonmemdc (crect client, CDC * pmemdc) {// draw it here}
You just need to draw it in paintonmemdc, and you don't need to care about anything else. Of course you can also take this stuff out ..