Skip to content

Commit 878b059

Browse files
amartya4256akoch-yatta
authored andcommitted
Handle Checkbox ImageList scaling in Table in win32
This commit handles scaling of ImageList in a table on DPI_CHANGE event by destroying the current imagelist and recalculating the height of the table item and then creating a new imagelist using the new size.
1 parent 7fa0622 commit 878b059

File tree

1 file changed

+21
-2
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets

1 file changed

+21
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7336,6 +7336,20 @@ LRESULT wmNotifyToolTip (NMTTCUSTOMDRAW nmcd, long lParam) {
73367336
return null;
73377337
}
73387338

7339+
void destroyImageList() {
7340+
// Bug in windows: Cannot set the imageList handle to 0 directly, it doesn't
7341+
// seems to cache the previous imageList and show flaky behavior. Instead set
7342+
// the size of the image to the minimum (1,1) and then set the imageList to 0.
7343+
long hImageList = OS.ImageList_Create (1, 1, 0, 0, 0);
7344+
long oldStateImageList = OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hImageList);
7345+
long oldhImageList = OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
7346+
OS.ImageList_Destroy(oldStateImageList);
7347+
OS.ImageList_Destroy(oldhImageList);
7348+
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, 0);
7349+
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
7350+
OS.ImageList_Destroy(hImageList);
7351+
}
7352+
73397353
@Override
73407354
void handleDPIChange(Event event, float scalingFactor) {
73417355
super.handleDPIChange(event, scalingFactor);
@@ -7358,6 +7372,12 @@ void handleDPIChange(Event event, float scalingFactor) {
73587372
imageList = null;
73597373
}
73607374

7375+
if((style & SWT.CHECK) != 0 ) {
7376+
destroyImageList();
7377+
int size = getItemHeightInPixels();
7378+
setCheckboxImageList(size, size, true);
7379+
}
7380+
73617381
// if the item height was set at least once programmatically with CDDS_SUBITEMPREPAINT,
73627382
// the item height of the table is not managed by the OS anymore e.g. when the zoom
73637383
// on the monitor is changed, the height of the item will stay at the fixed size.
@@ -7375,7 +7395,6 @@ void handleDPIChange(Event event, float scalingFactor) {
73757395
// Update scrollbar width if no columns are available
73767396
setScrollWidth(scrollWidth);
73777397
}
7378-
fixCheckboxImageListColor (true);
7379-
settingItemHeight = false;
7398+
settingItemHeight = false;
73807399
}
73817400
}

0 commit comments

Comments
 (0)