Un exemple vaut mieux qu'un long discours.
Voila donc un exemple en win32 :
HDC hdcScr, hdcMem;
int cx, cy, x1, y1, x2, y2;
HWND hwndScreen;
if (LockWindowUpdate(hwndScreen = GetDesktopWindow()))
{
hdcScr = GetDCEx (hwndScreen, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE);
hdcMem = CreateCompatibleDC (hdcScr);
cx = GetSystemMetrics(SM_CXSCREEN) / 10;
cy = GetSystemMetrics(SM_CYSCREEN) / 10;
srand ((int)GetCurrentTime());
for (int i=0;i<300;i++)
{
x1 = cx * (rand () % 10) ;
y1 = cy * (rand () % 10) ;
x2 = cx * (rand () % 10) ;
y2 = cy * (rand () % 10) ;
BitBlt(hdcMem, 0, 0, cx, cy, hdcScr, x1, y1, SRCCOPY) ;
BitBlt(hdcScr, x1, y1, cx, cy, hdcScr, x2, y2, SRCCOPY) ;
BitBlt(hdcScr, x2, y2, cx, cy, hdcMem, 0, 0, SRCCOPY) ;
}
DeleteDC(hdcMem);
ReleaseDC(hwndScreen, hdcScr);
//LockWindowUpdate(NULL);
}
c'est un truc marrant : il découpe ton écran en carrés et les échange de place. ca te fait un damier a l'écran.
voila.