HBITMAP ghBitmapMonochrome = 0;
HDC Create100x100WinGDC(void)
{
HDC hWinGDC;
HBITMAP hBitmapNew;
struct {
BITMAPINFOHEADER InfoHeader;
RGBQUAD ColorTable[256];
} Info;
void far *pSurfaceBits;
// Set up an optimal bitmap
if (WinGRecommendDIBFormat((BITMAPINFO far *)&Info) == FALSE)
return 0;
// Set the width and height of the DIB but preserve the
// sign of biHeight in case top-down DIBs are faster
Info.InfoHeader.biHeight *= 100;
Info.InfoHeader.biWidth = 100;
//*** DON'T FORGET A COLOR TABLE! ***
//*** COLOR TABLE CODE HERE ***
// Create a WinGDC and Bitmap, then select away
hWinGDC = WinGCreateDC();
if (hWinGDC)
{
hBitmapNew = WinGCreateBitmap(hWinGDC,
(BITMAPINFO far *)&Info, &pSurfaceBits);
if (hBitmapNew)
{
ghBitmapMonochrome = (HBITMAP)SelectObject(hWinGDC,
hBitmapNew);
}
else
{
DeleteDC(hWinGDC);
hWinGDC = 0;
}
}
return hWinGDC;
}
void Destroy100x100WinGDC(HDC hWinGDC)
{
HBITMAP hBitmapOld;
if (hWinGDC && ghBitmapMonochrome)
{
// Select the stock 1x1 monochrome bitmap back in
hBitmapOld = (HBITMAP)SelectObject(hWinGDC, ghBitmapMonochrome);
DeleteObject(hBitmapOld);
DeleteDC(hWinGDC);
}
}