Jump to content

Queation about resizing an image in guiCtrlCreatePic


Recommended Posts

Here is my program. I want to make the macBackground shrink/stretch to fit the MAC Hovering button. Whenever I do this, the button fails to bring up the MAC.exe program however when the pic is not stretched the program works fine.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Local $Button1, $b1label, $height, $width, $hPosition, $vPosition
$height = 75
$width = 80
$hPosition = IniRead("Mac.ini", "Desktop Position", "hPosition", "Mac.ini Not Found 100")
$vPosition = IniRead("Mac.ini", "Desktop Position", "vPosition", "Mac.ini Not Found 100")
GUICreate("MAC Hovering Button", $width, $height, $hPosition, $vPosition, $WS_POPUP, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Button1 = GUICtrlCreatePic("MacBackground.jpg", -1, -1)
GUICtrlSetState(-1, $GUI_DISABLE)
Opt("GUICoordMode", 2)
$b1label = GUICtrlCreateLabel("", 1, 1, $width, $height, 0x201)
GUICtrlSetBkColor($b1label, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($B1label, "Change")
GUISetState()

While 1
    Sleep(11)
WEnd
Func Change()
    If WinExists("MAC") Then; check to see if the MAC program is already running
        WinActivate("MAC"); makes MAC program active
    Else
        Run('MAC.exe') ; Starts MAC program
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc   ;==>_Exit

My Mac.ini looks like:

[Desktop Position]
hPosition=200
vPosition=200

and here is the MacBackground.jpg ->

I have tried changing:

$Button1 = GUICtrlCreatePic("MacBackground.jpg", -1, -1)

to

$Button1 = GUICtrlCreatePic("MacBackground.jpg", -1, -1, $width, $height)

Is there a way to do this? When I re-size the picture to equal the pixel measurements, the picture stretches and I can only see a small part of it.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Try this: $Button1 = GUICtrlCreatePic("un37K.jpg", 0, 0, $width, $height)

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Check out the filename of course! I used the filename as it is in attached pic!

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Check out the filename of course! I used the filename as it is in attached pic!

Br,

UEZ

I have the original jpg in my local au3 executing directory. Are you telling me to download the file I just uploaded and rename the file name?

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

No,

try this instead: $Button1 = GUICtrlCreatePic("MacBackground.jpg", 0, 0, $width, $height)

I used un37K.jpg instead of MacBackground.jpg as it was uploaded with that name.

The filename shouldn't be the problem!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

No,

try this instead: $Button1 = GUICtrlCreatePic("MacBackground.jpg", 0, 0, $width, $height)

I used un37K.jpg instead of MacBackground.jpg.

Br,

UEZ

you can actually get rid of $Button1 since it's no longer being used. The problem isn't that your suggestion has caused a picture not to show up, it shows up fine; it's just that when I have anything after the 0,0, then when the button is clicked nothing happens. When I remove the new data from the line then the program works fine again. Stretching the picture breaks the functionality.

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

Sorry,

but that code is working for me.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Local $Button1, $b1label, $height, $width, $hPosition, $vPosition
$height = 75
$width = 80
$hPosition = 200 ;IniRead("Mac.ini", "Desktop Position", "hPosition", "Mac.ini Not Found 100")
$vPosition = 200 ;IniRead("Mac.ini", "Desktop Position", "vPosition", "Mac.ini Not Found 100")
GUICreate("MAC Hovering Button", $width, $height, $hPosition, $vPosition, $WS_POPUP, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Button1 = GUICtrlCreatePic("un37K.jpg", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)
Opt("GUICoordMode", 2)
$b1label = GUICtrlCreateLabel("", -1, -1)
GUICtrlSetBkColor($b1label, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetOnEvent($B1label, "Change")
GUISetState()

While 1
    Sleep(11)
WEnd

Func Change()
    ConsoleWrite("huhu")
    If WinExists("MAC") Then; check to see if the MAC program is already running
        WinActivate("MAC"); makes MAC program active
    Else
        Run('MAC.exe') ; Starts MAC program
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc   ;==>_Exit

It displays the picture properly and when I click on the picture it executes the function change!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I just tried the following and it is working like a charm now. Thanks for the help.

$vPosition = IniRead("Mac.ini", "Desktop Position", "vPosition", "Mac.ini Not Found 100")
GUICreate("MAC Hovering Button", $width, $height, $hPosition, $vPosition, $WS_POPUP, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUICtrlSetState(-1, $GUI_DISABLE)
Opt("GUICoordMode", 2)
$b1label = GUICtrlCreatePic("MacBackground.jpg", 0, 0, $width, $height);GUICtrlCreateLabel("", 1, 1, $width, $height, 0x201)
GUICtrlSetBkColor($b1label, $GUI_BKCOLOR_TRANSPARENT);when disabled the box shows up grey (no pic)
GUICtrlSetOnEvent($B1label, "Change");when the button is clicked then "change" function is started
GUISetState()

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

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...