Modify

#3682 closed Bug (Fixed)

GuiCtrlCreatePic and the "set width and height to 0" feature

Reported by: anonymous Owned by: Jon
Milestone: 3.3.15.4 Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description

The help file says :
To set the picture control to the same size as the file content set width and height to 0.

While in AutoIt 3.3.12.0 this worked nice, in 3.3.14.5 this causes the image to be displayed in a 150x150 square

Attachments (0)

Change History (5)

comment:1 by Jpm, on Aug 10, 2020 at 12:41:43 PM

Owner: set to Jpm
Status: newassigned

Hi,
Fix send to Jon

comment:3 by Jon, on Jun 11, 2021 at 12:56:56 PM

Milestone: 3.3.15.4
Owner: changed from Jpm to Jon
Resolution: Fixed
Status: assignedclosed

Fixed by revision [12548] in version: 3.3.15.4

comment:4 by pixelsearch, on Jun 12, 2026 at 11:53:09 AM

Hello, I think we should reopen this bug.
Though a pic is displayed with this code, when w=0 and h=0 ...

GUICreate("My GUI", 600, 600)
Local $idPic = GUICtrlCreatePic(@ScriptDir & "\1272.jpg", 10, 10, 0, 0)

...what's the use of the fix, if the pic disappears as soon as the GUI is minimized / restored ?

I mean everything worked perfectly fine with AutoIt 3.3.14.2, no matter the GUI styles you indicated at GUI creation (just re-tested) : you could indicate $WS_OVERLAPPEDWINDOW and the pic showed in the control (it won't show at all with AutoIt 3.3.18.0)

You could maximize, resize, minimize, restore the GUI and the pic was still displayed correctly. Actually, as soon as you start to resize a GUI (or minimize) created with BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX) then the pic disappears immediately etc...

Could you please re-apply the same code found in AutoIt 3.3.14.2 so this issue will be correctly fixed ?
Thanks !

PS: if it can't be fixed, then let's forget these w=0 and h=0 parameters, sticking to GDI+ to get the width & height of the image, as we always did these last years.

comment:5 by pixelsearch, on Jun 12, 2026 at 7:33:20 PM

Note: if you want to avoid GDI+ in your code, then you can apply this 3 lines patch :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
	Local $sImage = @ScriptDir & "\mouette resized 1024x768.jpg" ; change to your .jpg (try a big pic > Gui client size)
	; Local $sImage = @ScriptDir & "\Grid 1920x1080.jpg"

	GUICreate("Reveal background", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED)
	Local $idPic = GUICtrlCreatePic($sImage, 0, 0, 0, 0)

	; patch w=0 & h=0 with the 3 following lines (avoids GDI+ in user's code)
	Local $aPicSize = WinGetClientSize(GUICtrlGetHandle($idPic))
	GUICtrlDelete($idPic)
	$idPic = GUICtrlCreatePic($sImage, 0, 0, $aPicSize[0], $aPicSize[1])

	GUISetState(@SW_SHOW)

	While 1
		Switch GUIGetMsg()
			Case $GUI_EVENT_CLOSE
				Exit
		EndSwitch
	WEnd
EndFunc   ;==>Example

Now no issue appears when you minimize the GUI or resize it : the pic is always correctly displayed with last AutoIt versions.

Modify Ticket

Action
as closed The owner will remain Jon.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.