@@ -530,6 +530,15 @@ public class Display extends Device implements Executor {
530
530
static int SWT_RESTORECARET ;
531
531
static int DI_GETDRAGIMAGE ;
532
532
static int SWT_OPENDOC ;
533
+ private static int ICON_SIZE_AT_100 = retrieveDefaultIconSize ();
534
+
535
+ private static int retrieveDefaultIconSize () {
536
+ if (OS .WIN32_BUILD >= OS .WIN32_BUILD_WIN10_1607 ) {
537
+ return OS .GetSystemMetricsForDpi (OS .SM_CXICON , DPIUtil .mapZoomToDPI (100 ));
538
+ } else {
539
+ return 32 ;
540
+ }
541
+ }
533
542
534
543
/* Skinning support */
535
544
Widget [] skinList = new Widget [GROW_SIZE ];
@@ -2552,33 +2561,44 @@ Font getSystemFont (int zoom) {
2552
2561
*/
2553
2562
public Image getSystemImage (int id ) {
2554
2563
checkDevice ();
2555
- int primaryMonitorNativeZoom = getPrimaryMonitor ().getZoom ();
2556
2564
switch (id ) {
2557
2565
case SWT .ICON_ERROR : {
2558
2566
if (errorImage != null ) return errorImage ;
2559
- long hIcon = OS . LoadImage ( 0 , OS .OIC_HAND , OS . IMAGE_ICON , 0 , 0 , OS . LR_SHARED );
2560
- return errorImage = Image . win32_new ( this , SWT . ICON , hIcon , primaryMonitorNativeZoom ) ;
2567
+ errorImage = new Image ( this , getImageDataProviderForIcon ( OS .OIC_HAND ) );
2568
+ return errorImage ;
2561
2569
}
2562
2570
case SWT .ICON_WORKING :
2563
2571
case SWT .ICON_INFORMATION : {
2564
2572
if (infoImage != null ) return infoImage ;
2565
- long hIcon = OS . LoadImage ( 0 , OS .OIC_INFORMATION , OS . IMAGE_ICON , 0 , 0 , OS . LR_SHARED );
2566
- return infoImage = Image . win32_new ( this , SWT . ICON , hIcon , primaryMonitorNativeZoom ) ;
2573
+ infoImage = new Image ( this , getImageDataProviderForIcon ( OS .OIC_INFORMATION ) );
2574
+ return infoImage ;
2567
2575
}
2568
2576
case SWT .ICON_QUESTION : {
2569
2577
if (questionImage != null ) return questionImage ;
2570
- long hIcon = OS . LoadImage ( 0 , OS .OIC_QUES , OS . IMAGE_ICON , 0 , 0 , OS . LR_SHARED );
2571
- return questionImage = Image . win32_new ( this , SWT . ICON , hIcon , primaryMonitorNativeZoom ) ;
2578
+ questionImage = new Image ( this , getImageDataProviderForIcon ( OS .OIC_QUES ) );
2579
+ return questionImage ;
2572
2580
}
2573
2581
case SWT .ICON_WARNING : {
2574
2582
if (warningIcon != null ) return warningIcon ;
2575
- long hIcon = OS . LoadImage ( 0 , OS .OIC_BANG , OS . IMAGE_ICON , 0 , 0 , OS . LR_SHARED );
2576
- return warningIcon = Image . win32_new ( this , SWT . ICON , hIcon , primaryMonitorNativeZoom ) ;
2583
+ warningIcon = new Image ( this , getImageDataProviderForIcon ( OS .OIC_BANG ) );
2584
+ return warningIcon ;
2577
2585
}
2578
2586
}
2579
2587
return null ;
2580
2588
}
2581
2589
2590
+ private ImageDataProvider getImageDataProviderForIcon (int iconName ) {
2591
+ return zoom -> {
2592
+ int scaledIconSize = DPIUtil .scaleUp (ICON_SIZE_AT_100 , zoom );
2593
+ long [] hIcon = new long [1 ];
2594
+ OS .LoadIconWithScaleDown (0 , iconName , scaledIconSize , scaledIconSize , hIcon );
2595
+ Image image = Image .win32_new (this , SWT .ICON , hIcon [0 ], zoom );
2596
+ ImageData imageData = image .getImageData (zoom );
2597
+ image .dispose ();
2598
+ return imageData ;
2599
+ };
2600
+ }
2601
+
2582
2602
/**
2583
2603
* Returns the single instance of the system-provided menu for the application, or
2584
2604
* <code>null</code> on platforms where no menu is provided for the application.
0 commit comments