Thanks. I tried implementing that stuff, and got it to draw a load of random lines which stayed on the screen. Here's my code so far.
Originally Posted by novacain
static HDC hdcScr = NULL;
static HBITMAP hbmpScr = NULL, hbmpOrig = NULL;
static RECT r;
pCtrl = new Controller (hwnd, reinterpret_cast<CREATESTRUCT *> (lParam));
// Store pointer to Controller inside Window
WinSetLong<Controller *> (hwnd, pCtrl);
SetTimer(hwnd, IDT_TIMER1, 500, (TIMERPROC) NULL); // no timer callback
// Text output stuff.
hdc = GetDC(hwnd);
hdcScr = CreateCompatibleDC(NULL);
x = GetDeviceCaps (hdcScr, HORZRES);
y = GetDeviceCaps (hdcScr, VERTRES);
hbmpOrig = CreateCompatibleBitmap(hdcScr, x, y);
SetRect(&r, 0, 0, x, y);
Rectangle(hdcScr, r.left, r.top, r.right, r.bottom);
FillRect(hdcScr, &r, (HBRUSH)GetStockObject(WHITE_BRUSH));
hdc = BeginPaint(hwnd, &ps);
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top, //only redraw the invalid area, not the whole screen.
hdcScr, //from mem DC
ps.rcPaint.left, ps.rcPaint.top, //assuming no offset for the image
Does some of that seem ok? I know I haven't deleted stuff properly but I'm just trying to get the basics going first. It seems to do what it's supposed to, but there's something I don't understand.
hdc = GetDC(hwnd);
::MoveToEx (hdcScr, rand() % 300, rand() % 300, 0);
::LineTo (hdcScr, rand() % 300, rand() % 300);
InvalidateRect(hwnd, NULL, FALSE);
Say I comment out everything after "ReleaseDC(hwnd, hdc);" in WM_CREATE, and comment out everything between "BeginPaint" and "EndPaint" in WM_PAINT. Then, if I change the hdcScr's in MoveToEx and LineTo to hdc, the lines will still draw, and stay on the screen.
Surely they should just appear and then disappear each time WM_PAINT gets called though? If stuff's not being copied to/from hdcSrc, why do they still stay on the screen?
This stuff is really bloody confusing, so thanks for your help- it's appreciated.