gc.fillRectangle (0, 0, width, height);
RECT rect = new RECT (); OS.SetRect (rect, 0, 0, width, height); drawBackground (gc.handle, rect);
LRESULT WM_PAINT (int wParam, int lParam) {	if ((state & CANVAS) == 0) {		return super.WM_PAINT (wParam, lParam);	}	/* Set the clipping bits */	int oldBits = 0, newBits = 0;	if (!OS.IsWinCE) {		oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE);		newBits = oldBits | OS.WS_CLIPSIBLINGS | OS.WS_CLIPCHILDREN;			if (newBits != oldBits) OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);	}	/* Paint the control and the background */	PAINTSTRUCT ps = new PAINTSTRUCT ();	if (hooks (SWT.Paint)) {		/* Create the paint GC */		GCData data = new GCData ();		data.ps = ps;		data.hwnd = handle;		GC gc = GC.win32_new (this, data);		/* Get the system region for the paint HDC */		int sysRgn = 0;		if ((style & (SWT.NO_MERGE_PAINTS | SWT.DOUBLE_BUFFERED)) != 0) {			sysRgn = OS.CreateRectRgn (0, 0, 0, 0);			if (OS.GetRandomRgn (gc.handle, sysRgn, OS.SYSRGN) == 1) {				if (OS.IsWinNT) {					POINT pt = new POINT();					OS.MapWindowPoints (0, handle, pt, 1);					OS.OffsetRgn (sysRgn, pt.x, pt.y);				}			}		}				/* Send the paint event */		int width = ps.right - ps.left;		int height = ps.bottom - ps.top;		if (width != 0 && height != 0) {			GC paintGC = null;			Image image = null;			if ((style & SWT.DOUBLE_BUFFERED) != 0) {				image = new Image (display, width, height);				paintGC = gc;				gc = new GC (image, style & SWT.RIGHT_TO_LEFT);				gc.setForeground (getForeground ());				gc.setBackground (getBackground ());				gc.setFont (getFont ());				if ((style & SWT.NO_BACKGROUND) != 0) {					paintGC.copyArea (image, ps.left, ps.top);				} else {					gc.fillRectangle (0, 0, width, height);				}				OS.OffsetRgn (sysRgn, -ps.left, -ps.top);				OS.SelectClipRgn (gc.handle, sysRgn);				OS.OffsetRgn (sysRgn, ps.left, ps.top);				OS.SetMetaRgn (gc.handle);					OS.SetWindowOrgEx (gc.handle, ps.left, ps.top, null);			}			Event event = new Event ();			event.gc = gc;						RECT rect = null;			if ((style & SWT.NO_MERGE_PAINTS) != 0 && OS.GetRgnBox (sysRgn, rect = new RECT ()) == OS.COMPLEXREGION) {				int nBytes = OS.GetRegionData (sysRgn, 0, null);				int [] lpRgnData = new int [nBytes / 4];				OS.GetRegionData (sysRgn, nBytes, lpRgnData);				int count = lpRgnData [2];				for (int i=0; i<count; i++) {					int offset = 8 + (i << 2);					OS.SetRect (rect, lpRgnData [offset], lpRgnData [offset + 1], lpRgnData [offset + 2], lpRgnData [offset + 3]);					if ((style & (SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND)) == 0) {						drawBackground (gc.handle, rect);					}					event.x = rect.left;					event.y = rect.top;					event.width = rect.right - rect.left;					event.height = rect.bottom - rect.top;					event.count = count - 1 - i;					/*					* It is possible (but unlikely), that application					* code could have disposed the widget in the paint					* event.  If this happens, attempt to give back the					* paint GC anyways because this is a scarce Windows					* resource.					*/					sendEvent (SWT.Paint, event);					if (isDisposed ()) break;				}			} else {				if ((style & (SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND)) == 0) {					if (rect == null) rect = new RECT ();					OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);					drawBackground (gc.handle, rect);				}				event.x = ps.left;				event.y = ps.top;				event.width = width;				event.height = height;				sendEvent (SWT.Paint, event);			}			// widget could be disposed at this point			event.gc = null;			if ((style & SWT.DOUBLE_BUFFERED) != 0) {				gc.dispose();				if (!isDisposed ()) {					paintGC.drawImage (image, ps.left, ps.top);				}				image.dispose ();				gc = paintGC;			}		}				/* Dispose the paint GC */		gc.dispose ();		if (sysRgn != 0) OS.DeleteObject (sysRgn);	} else {		int hDC = OS.BeginPaint (handle, ps);		if ((style & SWT.NO_BACKGROUND) == 0) {			RECT rect = new RECT ();			OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);			drawBackground (hDC, rect);		}		OS.EndPaint (handle, ps);	}	/* Restore the clipping bits */	if (!OS.IsWinCE && !isDisposed ()) { 		if (newBits != oldBits) {			/*			* It is possible (but unlikely), that application			* code could have disposed the widget in the paint			* event.  If this happens, don't attempt to restore			* the style.			*/			if (!isDisposed ()) {				OS.SetWindowLong (handle, OS.GWL_STYLE, oldBits);			}		}	}	return LRESULT.ZERO;}