It is easy to see why you see flickering in the window. You are performing two large drawing operations on the window device context.
First you appear to be clearing/erasing the window with a call to FillSolidRect:
Then later on you draw your bitmap bits into the device context.
These two large drawing operations may cause flicker because the call to FillSolidRect is being painted on the screen and visible for a very brief period. By the time you have drawn your bitmap the user has seen a flash of the background color.
I recommend the following:
1.) Make sure that you are not erasing the screen in response to the WM_ERASEBACKGROUND message.
2.) Implement a memory device context/bitmap and fill that with your FillSolidRect. Do all of your drawing inside these memory buffers.
3.) At the end of your OnPaint function bit blit the contents of your memory bitmap into the window device context in one fell swoop.
4.) If you still see flickering after this... make sure that all of the parent windows in the hierarchy are properly clipping.
Essentially you want 1 drawing operation on the device context associated with the window... not 2,3 or 30.
I would further recommend that you read Flicker Free Drawing In MFC
] by Keith Rule
]. Not only does the article have over a half million views... there are thousands of projects using his CMemDC class.
I believe that Microsoft added a CMemDC class of their own and gave it the same name with the MFC feature pack. So if you decide to use the CMemDC class and encounter a naming conflict keep this in mind.