|
19 | 19 |
|
20 | 20 | import org.eclipse.swt.*;
|
21 | 21 | import org.eclipse.swt.graphics.*;
|
| 22 | +import org.eclipse.swt.internal.*; |
22 | 23 | import org.eclipse.swt.internal.win32.*;
|
23 |
| -import org.eclipse.swt.widgets.*; |
24 | 24 |
|
25 | 25 | /**
|
26 | 26 | * Instances of this class represent programs and
|
@@ -379,9 +379,9 @@ public ImageData getImageData () {
|
379 | 379 | * @since 3.125
|
380 | 380 | */
|
381 | 381 | public ImageData getImageData (int zoom) {
|
382 |
| - // Windows API returns image data according to primary monitor zoom factor |
383 |
| - // rather than at original scaling |
384 |
| - int initialNativeZoom = Display.getCurrent().getPrimaryMonitor().getZoom(); |
| 382 | + // OS.SHGetFileInfo is System DPI-aware, hence it retrieves the icon with zoom |
| 383 | + // of primary monitor at the application startup |
| 384 | + int initialNativeZoom = getPrimaryMonitorZoomAtStartup(); |
385 | 385 | if (extension != null) {
|
386 | 386 | SHFILEINFO shfi = new SHFILEINFO ();
|
387 | 387 | int flags = OS.SHGFI_ICON | OS.SHGFI_USEFILEATTRIBUTES;
|
@@ -427,6 +427,13 @@ public ImageData getImageData (int zoom) {
|
427 | 427 | return imageData;
|
428 | 428 | }
|
429 | 429 |
|
| 430 | +private int getPrimaryMonitorZoomAtStartup() { |
| 431 | + long hDC = OS.GetDC(0); |
| 432 | + int dpi = OS.GetDeviceCaps(hDC, OS.LOGPIXELSX); |
| 433 | + OS.ReleaseDC(0, hDC); |
| 434 | + return DPIUtil.mapDPIToZoom(dpi); |
| 435 | +} |
| 436 | + |
430 | 437 | /**
|
431 | 438 | * Returns the receiver's name. This is as short and
|
432 | 439 | * descriptive a name as possible for the program. If
|
|
0 commit comments