   graphics refresh not happening in window
  I know I've seen this topic somewhere before, but once again it's a question of not knowing the right question to ask. Here's the situation: I create a window and display some bitmaps using ddraw - no problems there. The problem is refreshing the window. When I enter the main game loop, the graphics are erased. It seems to happen specifically when PeekMessage() is called. It also happens when the window is resized or minimized. I tried redrawing images each time through the loop, but everything started to flicker. I redraw when the user hits Enter, and that's fine, but I know it should work better than this. Here's my game loop:// WINMAIN ////////////////////////////////////////////////int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR lpcmdline,int ncmdshow){WNDCLASSEX winclass;  // this will hold the class we createMSG   msg;  // generic messageHDC   hdc;  // graphics device contextHPEN  pen=NULL;  // used to draw screen saverint color_change_count = 100; // used to track when to change color// first fill in the window class stucturewinclass.cbSize    = sizeof(WNDCLASSEX);winclass.style= CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW  ;winclass.lpfnWndProc= WindowProc;winclass.cbClsExtra= 0;winclass.cbWndExtra= 0;winclass.hInstance= hinstance;winclass.hIcon= LoadIcon(NULL, IDI_APPLICATION);winclass.hCursor= LoadCursor(NULL, IDC_ARROW); winclass.hbrBackground= (HBRUSH)GetStockObject(GRAY_BRUSH);winclass.lpszMenuName= NULL;winclass.lpszClassName= WINDOW_CLASS_NAME;winclass.hIconSm   = LoadIcon(NULL, IDI_APPLICATION);// save hinstance in globalhinstance_app = hinstance;// register the window classif (!RegisterClassEx(&winclass))return(0); // create the windowHWND hwnd ;if (!(hwnd = CreateWindowEx(WS_EX_DLGMODALFRAME, // extended styleWINDOW_CLASS_NAME,   // class"Black Jack", // titleWS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_MAXIMIZE  , 100,100, // initial x,yWINDOW_WIDTH, // initial widthWINDOW_HEIGHT,// initial heightNULL,  // handle to parent NULL,  // handle to menuhinstance,// instance of this applicationNULL)))  // extra creation parmsreturn(0);// save main window handlemain_window_handle = hwnd;// get the dc and hold onto ithdc = GetDC(hwnd);// seed random numbersrand(GetTickCount());InitDirectDraw(hwnd);srand(unsigned(time(NULL)));Deck *theDeck = new Deck() ;theDeck->Shuffle(true);Player *theHouse = new Player();theHouse->setName("The House") ;Player *player1 = new Player() ;player1->setName("Player 1") ; int totalscore = 0;bool hitTheHouse = false;startOver(theDeck, player1, theHouse, hwnd);SendMessage(hwnd, WM_SHOWWINDOW, 0, 0);while(true){   if ( theHouse->Score() == 21) {totalscore -= 10 ;hitTheHouse = false ;Draw_Text_GDI("YOU LOOSE!", 250, 350, RGB(0,255,0));}if (player1->Score() > 21){totalscore -= 10 ;hitTheHouse = false ;Draw_Text_GDI("YOU LOOSE!", 250, 350, RGB(0,255,0));}if (player1->Score() == 21){totalscore += 10 ;hitTheHouse = false ;Draw_Text_GDI("YOU WIN!", 250, 350, RGB(0,255,0));} while (hitTheHouse){if ( theHouse->Score() <= player1->Score() ) {Card *t = theDeck->Deal(theHouse) ;display(theHouse,hwnd, 1);}if ( theHouse->Score() > 21) {totalscore += 10 ;hitTheHouse= false;Draw_Text_GDI("YOU WIN!", 250, 350, RGB(0,255,0));}if ( theHouse->Score() == 21) {totalscore -= 10 ;hitTheHouse= false;Draw_Text_GDI("YOU LOOSE!", 250, 350, RGB(0,255,0));}if ( theHouse->Score() > player1->Score() && theHouse->Score() < 21 ){totalscore -= 10 ;hitTheHouse= false;Draw_Text_GDI("YOU LOOSE!", 250, 350, RGB(0,255,0));}}if (KEYDOWN(VK_RETURN)){startOver(theDeck, player1, theHouse, hwnd);SendMessage(hwnd, WM_SHOWWINDOW, 0, 0);display(theHouse,hwnd, 1);display(player1, hwnd, 0);}if (KEYDOWN('S'))hitTheHouse = true;if (KEYDOWN('H')&& player1->Score() < 21){theDeck->Deal(player1);display(theHouse,hwnd, 1);display(player1, hwnd, 0);}if (KEYDOWN(VK_ESCAPE))SendMessage(hwnd, WM_CLOSE, 0,0);    if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)){ if (msg.message == WM_QUIT)break;TranslateMessage(&msg);DispatchMessage(&msg);} // end ifSleep(100);} // end while// release the device contextreturn((int)msg.wParam);} // end WinMainAny help would be greatly appreciated.   
  The default handler for the WM_ERASEBKGND (sp?) message clears the background of your window. Try adding a handler for that message that just does nothing instead of letting it call DefWindowProc().;  That's got it! I don't know what I'd do without this forum! On that note, I would like to mention that I do actually try to answer these questions on my own - mostly using Google and the Visual Studio help files. Could you recommend any other good sources for 2D graphics issues like this one. I imagine I'm going down the same path that most 'noobs' travel and I'm not looking for any short cuts, just some good solid sources so I don't ask repetitive questions.Thanks again.   