FrancescoDiMuro Posted June 21, 2016 Share Posted June 21, 2016 Good morning everyone. I'm trying to do a simple thing, but, for now, it seems to be very difficult... Maybe, I'm missing something, so I'm asking here. I'm trying to let an image be clickable, so, I found out the _GUICtrlButton_SetImage function, which seems to very powerful. But for me, it doesn't work! $Motore1 = GUICtrlCreateButton("Something",10,10,58,54) _GUICtrlButton_SetImage($Motore1,"C:\Dynamics\PIC\LOCALI_HVAC181 - Copia.jpg") In this case, the image should fit in the button, right? Can someone help me out, please? Thanks Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AutoBert Posted June 21, 2016 Share Posted June 21, 2016 Works only with BMP's and ICON's. For BMP's the style $BS_BITMAP must be used. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 21, 2016 Author Share Posted June 21, 2016 I still can't use it... Even if I write this: $Motore1 = GUICtrlCreateButton("",10,10,58,54,$BS_BITMAP) _GUICtrlButton_SetImage($Motore1,"A.bmp") Why? Thank you for your answer Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2016 Moderators Share Posted June 21, 2016 FrancescoDiMuro, If you create the button using the native function, then use the native function to set the image - see the script below. Quote I'm trying to let an image be clickable Images are clickable - try clicking on both the button and image in this script: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> $sImage = "M:\Program\AutoIt3\Examples\GUI\Advanced\Images\Red.bmp" ; Adjust to match your AutoIt installation path $hGUI = GUICreate("Test", 500, 500) $cButton = GUICtrlCreateButton("", 10, 10, 80, 30, $BS_BITMAP) GUICtrlSetImage($cButton, $sImage) $cPic = GUICtrlCreatePic($sImage, 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton MsgBox($MB_SYSTEMMODAL, "Button", "Button clicked") Case $cPic MsgBox($MB_SYSTEMMODAL, "Image", "Image clicked") EndSwitch WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 21, 2016 Author Share Posted June 21, 2016 Thank you M23! You're my Script Hero! Ahahahah Ok, I understood the use of native functions GUICtrlCreateButton and GUICtrlSetImage For the BMP... Are there any restrictions about the width and height of the image? And, If the image is in the same folder where the script is running, the function GUICtrlSetImage doesn't need the whole path where the image stands, is it right? Thank you M23. You're the one that manage to help me when I have problem with script... A very big thank you! Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2016 Moderators Share Posted June 21, 2016 FrancescoDiMuro, As far as I know there are no restrictions on the size of the BMP - just try with your image file and see if it works. And, yes, if the image file is in the same folder as the script then all you need is the filename. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 21, 2016 Author Share Posted June 21, 2016 Again a big thank you M23. Have a wonderful day! -Francesco Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 21, 2016 Moderators Share Posted June 21, 2016 FrancescoDiMuro, Glad I could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now