diff options
author | Silenio Quarti <silenio> | 2004-04-08 18:47:47 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2004-04-08 18:47:47 +0000 |
commit | c57e6709ba1f97c13687499427427413c1eb3b48 (patch) | |
tree | 888d14424b03f71c66d8b3edf11bdb66ee6a2c38 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse | |
parent | 08734f1d9217f5c1e4c2264ddc5ef8916987021c (diff) | |
download | eclipse.platform.swt-c57e6709ba1f97c13687499427427413c1eb3b48.tar.gz eclipse.platform.swt-c57e6709ba1f97c13687499427427413c1eb3b48.tar.xz eclipse.platform.swt-c57e6709ba1f97c13687499427427413c1eb3b48.zip |
53632
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse')
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java | 19 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java | 22 |
2 files changed, 29 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java index b748fea7f1..51ca43b34b 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java @@ -450,6 +450,25 @@ public FontData [] getFontList (String faceName, boolean scalable) { return result; } +String getLastError () { + int error = OS.GetLastError(); + if (error == 0) return ""; + return " [GetLastError=0x" + Integer.toHexString(error) + "]"; +} + +String getLastErrorText () { + int error = OS.GetLastError(); + if (error == 0) return ""; + int[] buffer = new int[1]; + int dwFlags = OS.FORMAT_MESSAGE_ALLOCATE_BUFFER | OS.FORMAT_MESSAGE_FROM_SYSTEM | OS.FORMAT_MESSAGE_IGNORE_INSERTS; + int length = OS.FormatMessage(dwFlags, 0, error, OS.LANG_USER_DEFAULT, buffer, 0, 0); + if (length == 0) return " [GetLastError=0x" + Integer.toHexString(error) + "]"; + TCHAR buffer1 = new TCHAR(0, length); + OS.MoveMemory(buffer1, buffer[0], length * TCHAR.sizeof); + if (buffer[0] != 0) OS.LocalFree(buffer[0]); + return buffer1.toString(0, length); +} + /** * Returns the matching standard color for the given * constant, which should be one of the color constants diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java index 82b342e963..fd636e8100 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java @@ -1352,21 +1352,19 @@ void init(Device device, int width, int height) { } this.device = device; type = SWT.BITMAP; - - /* Get the HDC for the device */ int hDC = device.internal_new_GC(null); - - /* Fill the bitmap with the current background color */ handle = OS.CreateCompatibleBitmap(hDC, width, height); - if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); - int memDC = OS.CreateCompatibleDC(hDC); - int hOldBitmap = OS.SelectObject(memDC, handle); - OS.PatBlt(memDC, 0, 0, width, height, OS.PATCOPY); - OS.SelectObject(memDC, hOldBitmap); - OS.DeleteDC(memDC); - - /* Release the HDC for the device */ + if (handle != 0) { + int memDC = OS.CreateCompatibleDC(hDC); + int hOldBitmap = OS.SelectObject(memDC, handle); + OS.PatBlt(memDC, 0, 0, width, height, OS.PATCOPY); + OS.SelectObject(memDC, hOldBitmap); + OS.DeleteDC(memDC); + } device.internal_dispose_GC(hDC, null); + if (handle == 0) { + SWT.error(SWT.ERROR_NO_HANDLES, null, device.getLastError()); + } } /** |