Sign in to follow this  
Followers 0
Fraser

Pic button deforms after being minimized

4 posts in this topic

#1 ·  Posted (edited)

Hi,

I have created a custom picture button for my gui, however after minimizing/maximizing the gui the picture is stretched and I can't figure out a way to get it to get back to normal.

Here are the main bit of the code:

Creation of the button

$pic_min = GUICtrlCreatePic(@TempDir & "\PW Generator\images\x_min_1" & $header_colour & ".gif", 550, 0, 0, 0)

Case to minimize the gui when the button is pressed

Case $pic_min
GUISetState(@SW_MINIMIZE, $main)

Function to switch the image on hover

$cursor = GUIGetCursorInfo($main)
        If Not @error Then
            Select
                Case $cursor[4] = $pic_exit And $Icon1UnderCursor = False
                    GUICtrlSetImage($pic_exit, @TempDir & "\PW Generator\images\x_close_2" & $header_colour & ".gif")
;~                  MsgBox(0, "test", "Test")
                    $Icon1UnderCursor = True
                Case $cursor[4] <> $pic_exit And $Icon1UnderCursor
                    GUICtrlSetImage($pic_exit, @TempDir & "\PW Generator\images\x_close_1" & $header_colour & ".gif")
;~                  MsgBox(0, "test2", "Test2")
                    $Icon1UnderCursor = False
                Case $cursor[4] = $pic_min And $Icon2UnderCursor = False
                    GUICtrlSetImage($pic_min, @TempDir & "\PW Generator\images\x_min_2" & $header_colour & ".gif")
;~                  MsgBox(0, "test", "Test")
                    $Icon2UnderCursor = True
                Case $cursor[4] <> $pic_min And $Icon2UnderCursor
                    GUICtrlSetImage($pic_min, @TempDir & "\PW Generator\images\x_min_1" & $header_colour & ".gif")
;~                  MsgBox(0, "test2", "Test2")
                    $Icon2UnderCursor = False
            EndSelect
        EndIf

and here are the before and after images:

Before

19g9.png

After

do04.png

Does anyone have an idea that could help please? If you need anymore info please let me know!

Regards,
Fraser

Edited by Fraser

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I don't know but have you kept the default resizing to $GUI_DOCKSIZE for the pic? If you used GuiResizeMode it might have overridden the setting for the pic. Though if the size before minimizing is the same as maximized, which it looks like from your screen shots, then it shouldn't make any difference.

To get it back to the correct size you could get the dimensions after creating it by using ControlGetPos, then write a handler for OnExitSizeMove and use ControlMove, though it's a cludge.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for the advise.

I have figured it out (something so simple), so for reference, I should have specified the Width and Height of the picture.

$pic_min = GUICtrlCreatePic(@TempDir & "\PW Generator\images\x_min_1" & $header_colour & ".gif", 550, 0, 30, 18)
Edited by Fraser

Share this post


Link to post
Share on other sites

Ah, interesting to know that, it could save me a problem in the future.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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