Sign in to follow this  
Followers 0
RobbyCeyssens

GUICtrlSetImage not resizing image to previous image dimensions

4 posts in this topic

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Almost forgot to thank you guys for helping me out !

Share this post


Link to post
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
Sign in to follow this  
Followers 0