gc = new GC (image);
gc = new GC (image, style & SWT.RIGHT_TO_LEFT);
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)) {				/* Get the damage */		int [] lpRgnData = null;		boolean isComplex = false;		boolean exposeRegion = false;		int rgn = 0;		if ((style & (SWT.NO_MERGE_PAINTS | SWT.DOUBLE_BUFFERED)) != 0) {			rgn = OS.CreateRectRgn (0, 0, 0, 0);			isComplex = OS.GetUpdateRgn (handle, rgn, false) == OS.COMPLEXREGION;		}		if ((style & SWT.NO_MERGE_PAINTS) != 0) {			if (isComplex) {				int nBytes = OS.GetRegionData (rgn, 0, null);				lpRgnData = new int [nBytes / 4];				exposeRegion = OS.GetRegionData (rgn, nBytes, lpRgnData) != 0;			}		}			/* Create the paint GC */		GCData data = new GCData ();		data.ps = ps;		data.hwnd = handle;		GC gc = GC.win32_new (this, data);				/* 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);				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 (rgn, -ps.left, -ps.top);				OS.SelectClipRgn (gc.handle, rgn);				OS.SetMetaRgn (gc.handle);				OS.SetWindowOrgEx (gc.handle, ps.left, ps.top, null);			}			Event event = new Event ();			event.gc = gc;			if (isComplex && exposeRegion) {				RECT rect = new RECT ();				int count = lpRgnData [2];				for (int i=0; i<count; i++) {					OS.SetRect (rect,						lpRgnData [8 + (i << 2)],						lpRgnData [8 + (i << 2) + 1],						lpRgnData [8 + (i << 2) + 2],						lpRgnData [8 + (i << 2) + 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) {					RECT 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 (rgn != 0) OS.DeleteObject (rgn);	} 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) { 		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;}