Although the preferred method of associating a DIB with a device context is by using CreateDC, you can associate a new DIB with an existing DIB driver display context using the SELECTDIB escape, as shown in the following example:
Escape (hdc, SELECTDIB, sizeof(BITMAPINFOHEADER), (LPSTR)lpbi,
(LPSTR)lpBits)
For this example, hdc is a handle to a DIB-driver device context, lpbi points to a BITMAPINFOHEADER that describes the DIB, and lpBits points to the DIB bits. If lpBits is NULL, the bits are assumed to follow the DIB color table.
Use the SELECTDIB escape to only change the pointer to the DIB bits. Do not change the size of the DIB or the bit depth in the BITMAPINFOHEADER.