Obscure GUI Picture-related bug
Posted: 07 Mar 2018, 15:16
Introduction
I came across these obscure GUI bugs quite by accident. I'm posting them here because I'm not sure that the bugs can be reproduced on other computers.
The Bugs
There are two bugs that I found but the problem may affect other GUI commands.
Bug 1: The "gui,Add" command sometimes does not correctly identify the size of an icon.
Bug 2: The GUIControl command sometimes does not correctly identify the size of an icon and (this is the part that alarms me) will sometimes change the size of the control when updating the contents.
Script
Reproducing the Bugs
The bugs occur with icon index 115 of the "Shell32.dll" file. After the script starts, press the Down key to get to icon index 115. Once the images for icon index 115 are displayed, all other icons are displayed with the wrong size. The completely unexpected part is that the GUIControl command changes the size of the control when this bug occurs. And once the size of the control is changed to a smaller size, it is never changed back.
These bugs do not occur if the icon for index 115 is never shown. All of the icons are displayed as expected.
These bugs also occur if the image is loaded without the LoadPicture function. For example,
Help
Like I said, I have no idea whether this bug can be reproduced on other computers. Please let me know either way.
Edit: This bug is occurring on my Win7 Pro machine. Let me know which Windows version you are running on. Thanks.
I came across these obscure GUI bugs quite by accident. I'm posting them here because I'm not sure that the bugs can be reproduced on other computers.
The Bugs
There are two bugs that I found but the problem may affect other GUI commands.
Bug 1: The "gui,Add" command sometimes does not correctly identify the size of an icon.
Bug 2: The GUIControl command sometimes does not correctly identify the size of an icon and (this is the part that alarms me) will sometimes change the size of the control when updating the contents.
Script
Code: Select all
#NoEnv
#SingleInstance Force
ListLines Off
;-- Initialize
File :="shell32.dll"
;-- Load and count files
ListOfIndexes :=""
Loop 306
ListOfIndexes.=(A_Index>1 ? "|":"") . A_Index
;-- Choose a random Index
;;;;;Random RandomIndex,1,306
RandomIndex :=112
;-- Build GUI
gui -DPIScale -MinimizeBox
gui Add,Text,xm,16x16:
gui Add,Picture,xm y+1 vLP16,% "HICON: " . LoadPicture(File,"Icon" . RandomIndex . " w16 h16",IconType)
gui Add,Text,xm,24x24:
gui Add,Picture,xm y+1 vLP24,% "HICON: " . LoadPicture(File,"Icon" . RandomIndex . " w24 h24",IconType)
gui Add,Text,xm,32x32:
gui Add,Picture,xm y+1 vLP32,% "HICON: " . LoadPicture(File,"Icon" . RandomIndex . " w32 h32",IconType)
gui Add,Text,xm,48x48:
gui Add,Picture,xm y+1 vLP48,% "HICON: " . LoadPicture(File,"Icon" . RandomIndex . " w48 h48",IconType)
gui Add,Text,xm,64x64:
gui Add,Picture,xm y+1 vLP64,% "HICON: " . LoadPicture(File,"Icon" . RandomIndex . " w64 h64",IconType)
GUIControlGet LP64Pos,Pos,LP64
gui Add,Text,xm y+0 vLP64Size,Control size: %LP64PosW%x%LP64PosH%
gui Add,Text,xm,128x128:
gui Add,Picture,xm y+1 vLP128,% "HICON: " . LoadPicture(File,"Icon" . RandomIndex . " w128 h128",IconType)
GUIControlGet LP128Pos,Pos,LP128
gui Add,Text,xm y+0 vLP128Size,Control size: %LP128PosW%x%LP128PosH%
;;;;;gui Add,Picture,xm w128 h128 Icon115,Shell32.dll
gui Add,DropDownList,xm r12 Choose%RandomIndex% vDDL gUpdateIcons,%ListOfIndexes%
gui Add,Button,xm gReload Default,%A_Space% Reload... %A_Space%
;-- Show it
gui Show
GUIControl Focus,DDL
return
GUIEscape:
GUIClose:
ExitApp
Reload:
Reload
return
UpdateIcons:
gui Submit,NoHide
GUIControl,,LP16,% "HICON: " . LoadPicture(File,"Icon" . DDL . " w16 h16",IconType)
GUIControl,,LP24,% "HICON: " . LoadPicture(File,"Icon" . DDL . " w24 h24",IconType)
GUIControl,,LP32,% "HICON: " . LoadPicture(File,"Icon" . DDL . " w32 h32",IconType)
GUIControl,,LP48,% "HICON: " . LoadPicture(File,"Icon" . DDL . " w48 h48",IconType)
GUIControl,,LP64,% "HICON: " . LoadPicture(File,"Icon" . DDL . " w64 h64",IconType)
GUIControlGet LP64Pos,Pos,LP64
GUIControl,,LP64Size,Control size: %LP64PosW%x%LP64PosH%
GUIControl,,LP128,% "HICON: " . LoadPicture(File,"Icon" . DDL . " w128 h128",IconType)
GUIControlGet LP128Pos,Pos,LP128
GUIControl,,LP128Size,Control size: %LP128PosW%x%LP128PosH%
return
The bugs occur with icon index 115 of the "Shell32.dll" file. After the script starts, press the Down key to get to icon index 115. Once the images for icon index 115 are displayed, all other icons are displayed with the wrong size. The completely unexpected part is that the GUIControl command changes the size of the control when this bug occurs. And once the size of the control is changed to a smaller size, it is never changed back.
These bugs do not occur if the icon for index 115 is never shown. All of the icons are displayed as expected.
These bugs also occur if the image is loaded without the LoadPicture function. For example,
Code: Select all
gui Add,Picture,xm w128 h128 Icon115,Shell32.dll
Like I said, I have no idea whether this bug can be reproduced on other computers. Please let me know either way.
Edit: This bug is occurring on my Win7 Pro machine. Let me know which Windows version you are running on. Thanks.