I know I'm a little late to the part on this, but can I suggest a small tweak to this (very helpful) function? Unless I'm misunderstanding, it looks like at the moment that it assumes that your starting point is always a 16x16 image. But if I had a larger button with an image that was 32x32, then this function will actually make it smaller when running at 125% scaling because it will set it be size 24x24
I'm sure there's a more elegant way of handling this, but I changed it to:
Code:
Function GetCorrectIconSize Returns Integer
Integer iPixelsX iIndex iSize
Integer[] iaSizes
Move 16 to iaSizes[0]
Move 24 to iaSizes[1]
Move 32 to iaSizes[2]
Move 48 to iaSizes[3]
Move 64 to iaSizes[4]
Get piImageSize to iSize // the "100%" size
Move (SearchArray(iSize,iaSizes)) to iIndex
Move (0 max iIndex) to iIndex
Get GetCurrentDPI to iPixelsX
// Use a Case Statement here. Wherever we jump in we will continue onwards, regardless of whether
// we match the remaining Case statements or not. So list our Cases in reverse order, meaning we
// will increment iIndex as many times as we need here.
Case Begin
Case (iPixelsX > 144)
Increment iIndex
Case (iPixelsX = 144)
Increment iIndex
Case (iPixelsX = 120)
Increment iIndex
Case End
Move (iIndex min 4) to iIndex
Function_Return iaSizes[iIndex]
End_Function
And then in the End_Construct_Object of my class I have:
Code:
Procedure End_Construct_Object
Integer iIconSize
Get GetCorrectIconSize to iIconSize
Set piImageSize to iIconSize
Forward Send End_Construct_Object
End_Procedure
So in my object I can set the piImageSize to 32 and at runtime it will be adjusted to 48 with 125% scaling. Or if I set it to 16 it will be adjusted to 24. etc