Console flicker updating when win32

I am trying to make the rectangle drawn by GDI will move with mouse cursor when user clicked the rectangle.And i am using this source as guide, example don't have that flashing bug, and look pretty smooth, but mine keep flashing, and i think because of this flashing my dragging code is not working.

You should not Get DC once and then hang onto the DC for the life of the program. The longer you have the DC 'gotten', the longer the OS has to have it locked.If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site. Creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the Create Window function.#7 If you are invalidating the window, you should also be handling the WM_PAINT message and validating the window with Begin Paint/End Paint.

Failure to do this will cause Windows to repeatedly send WM_PAINT messages (because it thinks the screen is constantly dirty).

If you're installing today's release of build 10061 for the Windows 10 Technical Preview, you might encounter some issues along the way.