Skip to content

Commit 521d007

Browse files
committed
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 63d5582 commit 521d007

File tree

1 file changed

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

1 file changed

+20
-2
lines changed

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

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

7339+
void destroyImageList() {
7340+
long oldStateImageList = OS.SendMessage(handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
7341+
long oldhImageList = OS.SendMessage(handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
7342+
long hImageList = OS.ImageList_Create (1, 1, 0, 0, 0);
7343+
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hImageList);
7344+
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
7345+
OS.ImageList_Destroy(oldStateImageList);
7346+
OS.ImageList_Destroy(oldhImageList);
7347+
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, 0);
7348+
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
7349+
OS.ImageList_Destroy(hImageList);
7350+
}
7351+
73397352
@Override
73407353
void handleDPIChange(Event event, float scalingFactor) {
73417354
super.handleDPIChange(event, scalingFactor);
@@ -7358,6 +7371,12 @@ void handleDPIChange(Event event, float scalingFactor) {
73587371
imageList = null;
73597372
}
73607373

7374+
if((style & SWT.CHECK) != 0 ) {
7375+
destroyImageList();
7376+
int size = getItemHeightInPixels();
7377+
setCheckboxImageList(size, size, false);
7378+
}
7379+
73617380
// if the item height was set at least once programmatically with CDDS_SUBITEMPREPAINT,
73627381
// the item height of the table is not managed by the OS anymore e.g. when the zoom
73637382
// on the monitor is changed, the height of the item will stay at the fixed size.
@@ -7375,7 +7394,6 @@ void handleDPIChange(Event event, float scalingFactor) {
73757394
// Update scrollbar width if no columns are available
73767395
setScrollWidth(scrollWidth);
73777396
}
7378-
fixCheckboxImageListColor (true);
7379-
settingItemHeight = false;
7397+
settingItemHeight = false;
73807398
}
73817399
}

0 commit comments

Comments
 (0)