gottygolly Posted November 3, 2015 Share Posted November 3, 2015 I wasn't sure how to search for this but I did try and couldn't find anything.In my script I have a for loop create a bunch of labels and through this I was wanting to be able to click on any label and call the function "_Click" so that I can change the color of the box accordingly.I originally started using @gui_ctrlid to get the id of the label but I realized that once I started adding more code it would mess with getting the correct id. I thought I could use the macro @gui_ctrlhandle but I'm not sure on how to interact with the control through this (normally I would use the ControlId)The code below should hopefully help you understand if you are confused.Func _Click() $id = @GUI_CtrlHandle GUICtrlSetBkColor($id,$color) EndFuncThanks for any help and if you need additional information please let me know so I can aid you in aiding me. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2015 Moderators Share Posted November 3, 2015 gottygolly,but I realized that once I started adding more code it would mess with getting the correct idI do not see why it should - ControlIDs to not vary unless you delete and recreate the associated control. This works just fine:#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") For $i = 0 To 9 GUICtrlCreateLabel("", 10, 10 + (30 * $i), 200, 20) GUICtrlSetBkColor(-1, 0xCCFFCC) GUICtrlSetOnEvent(-1, "_Click") Next GUISetState() While 1 Sleep(10) WEnd Func _Click() $cCID = @GUI_CtrlId GUICtrlSetBkColor($cCID, 0xFFCCCC) EndFunc Func _Exit() Exit EndFuncM23 gottygolly 1 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...
gottygolly Posted November 3, 2015 Author Share Posted November 3, 2015 (edited) I realized that the function that I posted I had modified and I modified it to work properly, in my script instead of having this:Func _Click() $id = @GUI_CtrlId GUICtrlSetBkColor($id,$color) EndFuncI had this:Func _Click() $id = @GUI_CtrlId GUICtrlSetBkColor($label[$id],$color) EndFuncA simple mistake but thank you for the help melba, I compared your example code to my script and found the error that way.Appreciate it! Edited November 3, 2015 by gottygolly 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