Black Bar on right and bottom and double buffer

There is a black bar on both the right side and(or) the bottom side of my view window if the background of the view window is white and OnSize is called to maximize the window.
To solve the problem, someone suggest me to create a memory device context, and create a bitmap, then choose this bitmap into the memory dc. All we draw is on the memory dc. When drawing work is done, we copy it back to the screen dc.

Now another problem appears. It seems in function SetPixelFormat, the handle of the memory dc does not works well with the case that PFD_DOUBLEBUFFER flag is set. In other words, function SetPixelFormat fails if flag PFD_DOUBLEBUFFER is set. Any one encountered the problem before? Any suggestions? Thanks a lot!