here is the case WM_PAINT code. I know what is going on with the blits, but I'm not so sure what is going on with the whole SelectObject and HBITMAP vs. BITMAP and hbmOld, HDC hDC, HDC hDCMem, why I need them all, etc.
1) Could someone just explain what each line is doing and why it is needed? I hate having code from tutorials that works but i dont know why.
2) I am learning this to start remaking my allegro game in windows api. could someone explain WHERE i put the code for drawing updated pictures like the ship, bullets, alien ship, etc. and WHERE should the code go for updating their positions? in the message loop (all in functions of course)? do i have to do something like PostMessage(WM_PAINT) whenever the user hits a key to move the ship or something that requires an updated picture to be drawn? thanks
HDC hDC = BeginPaint(hWnd, &ps);
HDC hDCMem = CreateCompatibleDC(hDC);
HBITMAP hbmOld = (HBITMAP)SelectObject(hDCMem, shipmask);
GetObject(ship, sizeof(bm), &bm);
BitBlt(hDC, 0, 0, bm.bmWidth, bm.bmHeight, hDCMem, 0, 0, SRCAND);
BitBlt(hDC, 0, 0, bm.bmWidth, bm.bmHeight, hDCMem, 0, 0, SRCPAINT); //(destination, x, y, size w, size h)