AustrianOak Posted July 12, 2008 Posted July 12, 2008 im using guictrlsetbkcolor on a label in a while loop and the label is constantly flickering very fast and I was wondering how can i make the flickering completely stop. the label background color is updating fine but it is flickering. i dont think sleep will work as all it does is pauses the loop...please help as i dont know what to do
Andreik Posted July 12, 2008 Posted July 12, 2008 I used this example: $GUI = GUICreate("LABEL",200,200,-1,-1) $LABEL = GUICtrlCreateLabel("TEST",50,50,100,100,0x01) GUISetState(@SW_SHOW) While 1 $MSG = GUIGetMsg() If $MSG = -3 Then Exit GUICtrlSetBkColor($LABEL,Random(0x000000,0xffffff,1)) Sleep(500) WEnd Sometimes it is flickering, maybe is important dimensions of label.
ChrisL Posted July 12, 2008 Posted July 12, 2008 im using guictrlsetbkcolor on a label in a while loop and the label is constantly flickering very fast and I was wondering how can i make the flickering completely stop. the label background color is updating fine but it is flickering. i dont think sleep will work as all it does is pauses the loop...please help as i dont know what to doAre you changing the colour everytime or is your loop just setting a colour which is possibly already set but you haven't taken that in to concideration so your just setting it again anyway? [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
mrbond007 Posted July 12, 2008 Posted July 12, 2008 Try AdlibEnable() Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight
AustrianOak Posted July 14, 2008 Author Posted July 14, 2008 (edited) Are you changing the colour everytime or is your loop just setting a colour which is possibly already set but you haven't taken that in to concideration so your just setting it again anyway?yeah pretty much Edited July 14, 2008 by nowagain
ChrisL Posted July 14, 2008 Posted July 14, 2008 yeah pretty muchWell don't!Store the current colour in a $variable, if the new colour is still the same as the old colour stored in teh $Variable then do nothing, if the new colour is different to that stored in the $variable then update the label colour and store the new colour in the $variable [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
AustrianOak Posted July 14, 2008 Author Posted July 14, 2008 How do I check what my label background color is. Is there another way besides using PixelGetColor()?
NELyon Posted July 14, 2008 Posted July 14, 2008 I had the same problem. Like ChrisL said, instead of checking what the background color is, Just store the color in a variable every time you change it, so you will still have the value on hand. Maybe this will give you some insight. It's a color picker I wrote a while ago. #include <GUIConstantsEx.au3> #Include <Misc.au3> #include <EditConstants.au3> Global $nCont = 0, $xColor = 0x000000, $iRunning = False $hGUI = GUICreate("ColorSelect_Tool", 220, 110, -1, -1) WinSetOnTop($hGUI, "", 1) $hColor = GUICtrlCreateLabel("", 0, 0, 50, 50) $hSelectColorFromScreen = GUICtrlCreateButton("Select Color from Screen", 70, 0) $hHex = GUICtrlCreateInput("", 1, 70, 100, -1, $ES_READONLY) GUICtrlSetBkColor($hHex, 0xFFFFFF) GUISetState() While 1 If GUIGetMsg() = $hSelectColorFromScreen Then Do If PixelGetColor(MouseGetPos(0), MouseGetPos(1)) <> $xColor Then $xColor = PixelGetColor(MouseGetPos(0), MouseGetPos(1)) GUICtrlSetBkColor($hColor, $xColor) GUICtrlSetData($hHex, "0x" & StringRight(Hex($xColor), 6)) EndIf Until _IsPressed(01) EndIf If GUIGetMsg() = -3 Then Exit EndIf WEnd Note how it only changes if the color under the mouse changes, rather than every time the loop iterates.
AustrianOak Posted July 14, 2008 Author Posted July 14, 2008 I think I found a way to solve this but I need to know if there is a way I can read a labels background and it will return it in hex. ?
JFee Posted July 14, 2008 Posted July 14, 2008 I don't really understand why you need to do that. Could you explain? Regards,Josh
AustrianOak Posted July 14, 2008 Author Posted July 14, 2008 Well I need it because if I can get the bkg color of the label in hex i can compare it to the hex values written in my ini and then determine if I need to change the color. Its very simple..
JFee Posted July 14, 2008 Posted July 14, 2008 You shouldn't need to do that. Have something like: $currentColor = "" ; Put other code here, then when you would normally change the color: If $currentColor <> $colorYouWantToChangeItTo Then GUICtrlSetBkColor($hLabel, $colorYouWantToChangeItTo) $currentColor = $colorYouWantToChangeItTo EndIf Regards,Josh
AustrianOak Posted July 14, 2008 Author Posted July 14, 2008 No. thats not going to work for my situation! muttley I already explained that I am going to have to get the color off my label bkg first. And the only way I can think of I PixelGetColor(). But for some strange reason, you don't have the option to have it reuturn in hex.
JFee Posted July 14, 2008 Posted July 14, 2008 But you didn't explain.... why do you need to get the color? Set it to something arbitrary, and when it does the If statement like I showed above, it will automatically change it. Would you care to post code? Regards,Josh
NELyon Posted July 14, 2008 Posted July 14, 2008 $xColor = PixelGetColor(50, 50) $Hex = "0x" & StringRight(Hex($xColor), 6)
AustrianOak Posted July 14, 2008 Author Posted July 14, 2008 #include <guiconstants.au3> #include <misc.au3> $font_Color = iniread(@ScriptDir & "\temp.dat", "font", "color", "0x000000") $gui = guicreate("", 300, 300) $ChooseTextColor = GUICtrlCreateLabel("", 30, 30, 30, 30) GUICtrlSetBkColor(-1, $font_Color) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit 0 Case $msg = $ChooseTextColor $hex = _ChooseColor(2, $font_Color, 2, $gui) If $hex = -1 Then Else IniWrite(@ScriptDir & "\temp.dat", "Font", "Color", $hex) EndIf EndSelect $return_Color = IniRead(@ScriptDir & "\temp.dat", "Font", "Color", "0x000000") GUICtrlSetBkColor($ChooseTextColor, $return_Color) Wend this is what my ini looks like at the beginning: [font] color=0x000000
AustrianOak Posted July 14, 2008 Author Posted July 14, 2008 $xColor = PixelGetColor(50, 50) $Hex = "0x" & StringRight(Hex($xColor), 6) thanks, thats what i needed. at JFee: thanks for helping too
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