Jump to content

GUICtrlSetImage not resizing image to previous image dimensions


 Share

Recommended Posts

Hi,

I created an image control and resize the image together with the window. When I update the image control with GUICtrlSetImage($Pic, "new_image.jpg") the image doesn't resize to the dimensions of the previous resized image. I found some topics concerning this problem with suggestions to use:

GUISetState (@SW_HIDE)

GUISetState (@SW_SHOW)

after GUICtrlSetImage($Pic, "new_image.jpg") but this doesn't seem to help.

If I don't resize the window everything works fine.

I'm using the latest stable version of AutoIt.

Thx

CODE
#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Opt("GUIResizeMode", $GUI_DOCKAUTO)

Example()

Func Example()

Local $msg, $Pic

Opt("GUICoordMode", 2)

GUICreate("My InputBox", 800, 600, -1, -1, $WS_SIZEBOX) ; start the definition

$Pic = GUICtrlCreatePic(@DesktopDir & "/test.jpg", 0, 0, 200, 200)

GUISetState() ; to display the GUI

; Run the GUI until the dialog is closed

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $Pic Then GUICtrlSetImage($Pic,@DesktopDir & "\test\images\01.jpg")

WEnd

EndFunc ;==>Example

Link to comment
Share on other sites

RobbyCeyssens

Welcome!

Try this:

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

Opt('MustDeclareVars', 1)
Opt("GUIResizeMode", $GUI_DOCKAUTO)

Example()

Func Example()
    Local $iPrevCoord, $hGUI, $msg, $Pic, $cSize
    
    Opt("GUICoordMode", 2)
    
    $hGUI = GUICreate("My InputBox", 800, 600, -1, -1, $WS_SIZEBOX) ; start the definition

    $Pic = GUICtrlCreatePic(@DesktopDir & "\test.jpg", 0, 0, 200, 200)

    GUISetState() ; to display the GUI

; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
        If $msg = $Pic Then
            $iPrevCoord = Opt("GUICoordMode", 1)
            $cSize = ControlGetPos($hGUI, "", $Pic)
            GUICtrlSetImage($Pic, @DesktopDir & "\test\images\01.jpg")
            GUICtrlSetPos($Pic, $cSize[0], $cSize[1], $cSize[2], $cSize[3])
            Opt("GUICoordMode", $iPrevCoord)
        EndIf
    WEnd
EndFunc ;==>Example

;)

Edited by rasim
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...