Interesting. However,
Carcophan wrote:
Test GDI+ color bug
... it's not GDI+. As Guest pointed out, it doesn't happen if you use AltSubmit. AltSubmit tells it to use GDI+. Using a PNG would have the same effect, since GDI+ is required to load it.
The inner workings of Gui,Color are very simple: when the colour is changed,
create a solid brush of the new colour; when a WM_ERASEBKGND message is received, call
FillRect using the background brush. It doesn't do much else.
Given that loading the image manually as below exhibits the same problem, I would rule out AutoHotkey's image-loading routine as the cause:
Code:
SS_BITMAP := 14 ; Required for it to show a bitmap.
STM_SETIMAGE := 0x172 ; Message used to set bitmap.
IMAGE_BITMAP := 0 ; Type of image.
LR_LOADFROMFILE := 0x10 ; Required flag to load from file.
LR_CREATEDIBSECTION := 0x2000 ; Optional flag, used by AHK but makes no difference.
; Add the Picture control with the appropriate style. Note that a "Text" control is
; exactly the same in this context: both are really a Windows "Static" control.
Gui, 2:Add, Picture, hwndhpic +%SS_BITMAP%
; Load the image with a basic GDI call.
hbmp := DllCall("LoadImage", "uint", 0, "str", "test img.bmp", "uint", IMAGE_BITMAP, "int", 0, "int", 0, "uint", LR_LOADFROMFILE|LR_CREATEDIBSECTION)
; Set the image.
SendMessage, STM_SETIMAGE, IMAGE_BITMAP, hbmp,, ahk_id %hpic%
Actually, this is more or less the same as what AutoHotkey does by default (and what I imagine the majority of GDI-based applications would do). As you can see, it only sets the image; actually drawing the image is up to Windows.
It seems vaguely familiar to me, like an obscure Windows "feature". I found that resizing the image put the colour off slightly (f0f0f0 -> efefef) and that prevented it from changing colour. However, if the image was loaded by GDI+, the colour remained f0f0f0.
If I had more time, I'd complete the test: create a Static control via CreateWindowEx, load and set the image as above, and handle WM_ERASEBKGND in script. I suspect it would have the same issue.