Mat Posted March 2, 2009 Share Posted March 2, 2009 (edited) Right now i'm trying to set an image as a button, this is the script from the help file; #Include <GuiButton.au3> _GUICtrlButton_SetImage([u][b]$hWnd[/b][/u], $sImageFile[, $nIconId = -1[, $fLarge = False]]) here is my script: $Start = _GUICtrlButton_Create("Start", -1, 0, 65, 30, $BS_BITMAP) _GUICtrlButton_SetImage(????????, $Start, $sPath & "\Start.bmp") everything else is fine - except The "Handle to the control". sorry for being a noob Mdiesel Edited March 2, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
jvanegmond Posted March 2, 2009 Share Posted March 2, 2009 $Start = _GUICtrlButton_Create("Start", -1, 0, 65, 30, $BS_BITMAP) _GUICtrlButton_SetImage($Start, $sPath & "\Start.bmp") So. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Mat Posted March 2, 2009 Author Share Posted March 2, 2009 Error: Invalid Window handle for _GUICtrlButton_Create 1st parameter AutoIt Project Listing Link to comment Share on other sites More sharing options...
GaryFrost Posted March 2, 2009 Share Posted March 2, 2009 Error:Invalid Window handle for _GUICtrlButton_Create 1st parameterYour missing the handle to the gui for the 1st param SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Mat Posted March 2, 2009 Author Share Posted March 2, 2009 Your missing the handle to the gui for the 1st param.... I guessed almost that much....what I was trying to ask is what the value should be...If someone could give it to me in english it would be nice too... AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2009 Moderators Share Posted March 2, 2009 mdiesel,This is my understanding of how it works - the purists will probably find it lacking, but it will do for you and me.;-)When you create "something" in Windows, it is identified by a "handle" - a unique identifier so that everyone/everything knows how to address the "something".When you create "something" in Autoit, it is given a "ControlID", unique to that script - and of course Windows gives it a "handle" as well.You can determine the handle from the ControlID (WinGetHandle & ControlGetHandle) and the ControlID from the handle (_WinAPI_GetDlgCtrlID).Internally, Autoit usually uses the ControlID, so in the case you posted:$Start = _GUICtrlButton_Create("Start", -1, 0, 65, 30, $BS_BITMAP) _GUICtrlButton_SetImage(????????, $Start, $sPath & "\Start.bmp")you need to use the ControlID of the button, which you have stored in $Start. So you need (as Manadar explained):$Start = _GUICtrlButton_Create("Start", -1, 0, 65, 30, $BS_BITMAP) _GUICtrlButton_SetImage($Start, $sPath & "\Start.bmp")Because AutoIt is a very pleasant language to use, you can also use "-1" to refer to the last ControlID, so you could code:$Start = _GUICtrlButton_Create("Start", -1, 0, 65, 30, $BS_BITMAP) _GUICtrlButton_SetImage(-1, $sPath & "\Start.bmp")I am afraid that there is a degree of confusion between the use of ControlID and handle in AutoIt (I just know I am going to get flamed for that, but it is true!). Normally, builtin AutoIt functions use the ControlID, but some UDFs use the Windows handle. A good UDF allows you to use either by checking with IsHwnd and doing any conversion for you.Still awake? Ask if anything is unclear, but I cannot guarantee you a better answer. :-)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...
GaryFrost Posted March 2, 2009 Share Posted March 2, 2009 A lot to say and still not the reason for the error. The user used the UDF function to create the button, tried to. It requires the handle to the gui where as the built-in function does not. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Mat Posted March 2, 2009 Author Share Posted March 2, 2009 (edited) Thanks a lot - that works now... not quite sure why or how - but i'll leave that up to the people who know what they're talking about. thanks again, Mdiesel oh, and i was missing the handle for the line before... Edited March 2, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 2, 2009 Moderators Share Posted March 2, 2009 GaryFrost, Guilty as charged.....but at least I tried to explain. 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