case WM_CREATE :
	gDC = WinGCreateDC ();			// create a WinG DC
	memset (&bmi, 0, sizeof (bmi));
	bmi.hdr.biSize = sizeof (bmi);
	WinGRecommendedDIBFormat (&bmi);	// get the DIB format
	bmi.hdr.biBitCount = 8;
	iDir = (int) bmi.hdr.biHeight;		// will be 1 or -1

	// Setup your palette here
	hPal = SelectPalette (...);
	break;

case WM_SIZE : {
	// note - a DIB width must be DWORD aligned
	bmi.hdr.biWidth = (LOWORD (lParam) + 3) & ~3;
	bmi.hdr.biHeight = HIWORD (lParam) * iDir;
	// pDIB points to the WinG DIB on return
	HBITMAP hbm = WinGCreateBitmap (gDC, &bmi, &pDIB);
	// attach DIB to the DC
	HBITMAP hPrevBm = (HBITMAP) SelectObject (gDC, hbm);
	DeleteObject (hPrevBm);
	break; }

case WM_PAINT : {
	PAINTSTRUCT ps;
	BeginPaint (hWnd, &ps);
	SelectPalette (ps.hdc, hPal, FALSE);	// set it to our palette
	RealizePalette (ps.hdc);

...						// build up the image in pDIB

	WinGBitBlt (ps.hdc, ps.rcPaint.left, ps.rcPaint.top,
					ps.rcPaint.right - ps.rcPaint.left,
					ps.rcPaint.bottom - ps.rcPaint.top,
					gDC, ps.rcPaint.left, ps.rcPaint.top);
	EndPaint (hWnd, &ps);
	return (0); }
