Jump to content

Auto re-sizing a pic in a window breaks the ability to tie the pic to a function


Recommended Posts

The following script creates a small window on the screen and then places a picture in the window and when I click the picture the program opens notepad.

#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Local $Button1, $b1label, $height, $width, $hPosition, $vPosition
$height = 100
$width = 100
$hPosition = $width
$vPosition = 1
GUICreate("MAC Hovering Button", $width, $height, @DesktopWidth - $hPosition, $vPosition, $WS_POPUP, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.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("[CLASS:Notepad]") Then; check to see if the MAC program is already running
        WinActivate("[CLASS:Notepad]"); makes MAC program active
    Else
        Run('notepad.exe') ; Starts MAC program
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc   ;==>_Exit

The above works fine. When I click the button notepad opens. The problem I was having was re-sizing the picture to fit into the window. I was able to get the picture to auto re-size into the window by changing the following line from

$Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.jpg", -1, -1)

to

$Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.jpg", -1, -1, $width, $height)

and

$Button1 = GUICtrlCreatePic("c:\Program Files\AutoIt3\Examples\GUI\MACFinal200x188.jpg", -1, -1, 100, 100)

both of the above break the change() function. Why? I can re-edit the picture I want to use each time but I would like to avoid that if I can. There also seems to be a discrepancy between the desktop resolution and the width and height of the GUICreate and GUICtrlCreatePic functions. I can only assume that the width and height options are not measured in pixels.

Edited by computergroove

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

There also seems to be a discrepancy between the desktop resolution and the width and height of the GUICreate and GUICtrlCreatePic functions. I can only assume that the width and height options are not measured in pixels.

You are a pixel.

:graduated:

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