Hotzenplotz Posted March 11, 2021 Share Posted March 11, 2021 Hi there i want to set labels with the same background color if one label is active. like if $x = true then GuiGUICtrlSetBkColor($lsong1, 0x000000) GUICtrlSetBkColor($lsong2, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($lsong3, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($lsong4, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($lsong5, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($lsong6, $GUI_BKCOLOR_TRANSPARENT) .......... endif must i do it like that ? or is there another way to do it. if i have 50 Labels its getting annoying Regards Link to comment Share on other sites More sharing options...
Nine Posted March 11, 2021 Share Posted March 11, 2021 (edited) Here one way. If True Then ; some condition For $i = 1 To 50 GUICtrlSetBkColor(Eval("lsong" & $i), $i = 1 ? 0x000000 : $GUI_BKCOLOR_TRANSPARENT) ; if $i = 1 black otherwise transparent Next EndIf I would suggest to use an Array for the creation instead of naming them individually : #include <GUIConstants.au3> GUICreate("") Local $aLabel[50] For $i = 0 To UBound($aLabel) - 1 $aLabel[$i] = GUICtrlCreateLabel("Test", 10, 10+$i*20, 100, 15) Next GUISetState() ; some code goes here Sleep (4000) ; for exmample only If True Then ; some condition For $i = 0 To UBound($aLabel) - 1 GUICtrlSetBkColor($aLabel[$i], $i = 1 ? 0x000000 : $GUI_BKCOLOR_TRANSPARENT) ; if $i = 1 black otherwise transparent Next EndIf ; some other code goes here Sleep(4000) ; for example only Edited March 11, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted March 11, 2021 Share Posted March 11, 2021 Just a brief note : @Hotzenplotz has asked this question simultaneously in the German forum too. To avoid duplication of work by possible helpers, here is the link : https://autoit.de/thread/87289-mehrere-labels-mit-gleichen-hintergrund-wenn-bedingung-erfüllt/ "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Hotzenplotz Posted March 11, 2021 Author Share Posted March 11, 2021 sorry for this 4 minutes ago, Musashi said: Just a brief note : @Hotzenplotz has asked this question simultaneously in the German forum too. To avoid duplication of work by possible helpers, here is the link : https://autoit.de/thread/87289-mehrere-labels-mit-gleichen-hintergrund-wenn-bedingung-erfüllt/ Link to comment Share on other sites More sharing options...
Musashi Posted March 11, 2021 Share Posted March 11, 2021 1 minute ago, Hotzenplotz said: sorry for this It's not that bad at all, just a matter of etiquette . The problem with crossposting is, that helpers spend their time without knowing about the respective responses in the other forum. Since we are all volunteers, time is precious and should not be wasted. pixelsearch, argumentum, mikell and 1 other 3 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
JockoDundee Posted March 11, 2021 Share Posted March 11, 2021 24 minutes ago, Musashi said: The problem with crossposting is, that helpers spend their time without knowing about the respective responses in the other forum. maybe polyglotonus cross-posting should be allowed if the poster is reasonably fluent in both languages the communities do not substantially overlap the poster communicates and translates relevant comments between groups Musashi 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Hotzenplotz Posted March 11, 2021 Author Share Posted March 11, 2021 (edited) 3 hours ago, Nine said: Here one way. If True Then ; some condition For $i = 1 To 50 GUICtrlSetBkColor(Eval("lsong" & $i), $i = 1 ? 0x000000 : $GUI_BKCOLOR_TRANSPARENT) ; if $i = 1 black otherwise transparent Next EndIf this worked for me first caus it is easy to understand but u are right with the array, I must get firm more and more with it. Thanks Mate Edited March 11, 2021 by Hotzenplotz Link to comment Share on other sites More sharing options...
Musashi Posted March 11, 2021 Share Posted March 11, 2021 40 minutes ago, JockoDundee said: maybe polyglotonus cross-posting should be allowed if ... I fully agree with you, that there are forms of crossposting that can be very useful (you've already named some). For example, there are nice scripts in the German forum (and in other country forums probably as well), that have never seen the light of day in the English forum (and vice versa). The reasons can be manifold. In some cases it fails due to lack of language skills, in others the author simply has no interest in it. If someone takes the effort to present a script in other forums and even explain its functionality, it will be a benefit for the entire AutoIt community . However, regarding the source code, there should always be only one central download location. Otherwise, there might be different versions, and no one knows in the end which is the right one. JockoDundee 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Hotzenplotz Posted March 12, 2021 Author Share Posted March 12, 2021 (edited) On 3/11/2021 at 8:51 PM, Nine said: Here one way. I would suggest to use an Array for the creation instead of naming them individually : #include <GUIConstants.au3> GUICreate("") Local $aLabel[50] For $i = 0 To UBound($aLabel) - 1 $aLabel[$i] = GUICtrlCreateLabel("Test", 10, 10+$i*20, 100, 15) Next GUISetState() ; some code goes here Sleep (4000) ; for exmample only If True Then ; some condition For $i = 0 To UBound($aLabel) - 1 GUICtrlSetBkColor($aLabel[$i], $i = 1 ? 0x000000 : $GUI_BKCOLOR_TRANSPARENT) ; if $i = 1 black otherwise transparent Next EndIf ; some other code goes here Sleep(4000) ; for example only I have done it now like this, how to set label font colors and tips was easy for me, but how do i give every label an event with differnt functions Edited March 12, 2021 by Hotzenplotz Link to comment Share on other sites More sharing options...
Hotzenplotz Posted March 13, 2021 Author Share Posted March 13, 2021 (edited) 23 hours ago, Hotzenplotz said: I have done it now like this, how to set label font colors and tips was easy for me, but how do i give every label an event with differnt functions i found out how to do it with using a array for the functions Edited March 13, 2021 by Hotzenplotz 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