where do you select a pen?

Code:
FillRect(mydc,&RectWindow,CreateSolidBrush(Color));
Note that you have a resource leak here as the created handle isn't deleted.