Jump to content

Problem with $WS_EX_COMPOSITED and $GUI_BKCOLOR_TRANSPARENT for label


HeJake
 Share

Recommended Posts

So, as the title says.

I am trying to make a gui with background image and without "sys" buttons and border ($WS_POPUP). Since i used image to make custom buttons and_lif with GetCursorInfo) to change image, changes was flickering. So for that i used $WS_EX_COMPOSITED. But! If you change label with transparent bg, they will overlap. Just for example:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form = GUICreate("Form", 420, 182, -1, -1, BitOR($WS_POPUP, $WS_EX_COMPOSITED))
GUISetBkColor(0x000000)
$Label = GUICtrlCreateLabel("", 150, 50, 15, 15)
GUICtrlSetFont($Label, 10)
GUICtrlSetColor($Label, 0xFFFFFF)
;GUICtrlSetBkColor($Label, $GUI_BKCOLOR_TRANSPARENT)
GUISetState(@SW_SHOW)

For $i = 1 To 100
GUICtrlSetData($Label, $i)
Sleep(10)
Next

After this, uncomment transparent bg and run again.

Any way to avoid this? Because i need to keep the label with transparent bg. (since bg image :) )

Or maybe there is another way to avoid flickering?

Also 1 more question, how do i make window move by clicking on body of it? I mean, game launchers (most of mmo) you able to move window just by holding mouse somewhere on the window (not only on the top as usual). I saw this somewhere, but can't find it :o

Link to comment
Share on other sites

Don't update the label so often, your GUICtrlSetData is running every 10 ms, so the label is going to flicker.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Also use GUICtrlRead to check if the data is different to what you're updating the control with.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Oh. My example was only an example to show you what's going on with label after update. :)

Of course my label doesn't update so often ( only few times, with conditions. )

Also there is only text. E.g: label was Hello, then label text was changed after 2 sec to Welcome, but the "Hello"

didn't clear, so that Welcome was "on" Hello. That is :) If i remove $GUI_BKCOLOR_TRANSPARENT from label, there is no probs, label updates well. But i need to keep transparency, because i have a label over an image. (It doesn't matter image or just color bg)

I used double buffering as i said for an image change ( like MouseOver, _ButtonHover, but with _lif and GUIGetCursorInfo ) it was flickering.

Link to comment
Share on other sites

$WS_CLIPCHILDREN and $WS_EX_COMPOSITED have the same value, so what you did was apply the first one to the standard Style setting, instead of setting $WS_EX_COMPOSITED to the extended style setting with your code above.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

So, to recap, it's not flickering, it's a redraw problem? Do you have an example of your script that demonstrates this with what it is you're trying to accomplish. Because all this one does is leaves a hole in the middle of the GUI with the numbers on top of each other.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Okay, first try this:

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#Include <Icons.au3>
$Form = GUICreate("Form", 500, 300, -1, -1, BitOR($WS_POPUP, $WS_EX_COMPOSITED))
$BG = GUICtrlCreatePic(@ScriptDir & "\bg.jpg", 0, 0, 500, 300)
GUICtrlSetState($BG, $GUI_DISABLE)
$Inf = GUICtrlCreateLabel("", 216, 116, 600, 17)
GUICtrlSetBkColor($Inf, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont($Inf, 10)
GUICtrlSetColor($Inf, 0xFFFFFF)
$cButton = GUICtrlCreatePic("", 440, 8, 35, 35)
_SetImage($cButton, @ScriptDir & "\closea.png")
$cButton2 = GUICtrlCreatePic("", 440, 8, 35, 35)
_SetImage($cButton2, @ScriptDir & "\closeb.png")
GUICtrlSetData($Inf, "Test text")
GUISetState(@SW_SHOW)

Sleep(2000)
GUICtrlSetData($Inf, "TEST TEXT")

While GUIGetMsg() <> $cButton
$aCursor = GUIGetCursorInfo($Form)
GUICtrlSetState($cButton2, _Iif(($aCursor[4] = $cButton2) And BitAND(GUICtrlGetState($cButton2), 16), $GUI_HIDE, _Iif($aCursor[4] <> $cButton And BitAND(GUICtrlGetState($cButton2), 32), $GUI_SHOW, 0)))
Sleep(10)
WEnd

Then with BitOR($WS_POPUP, 0)) And move mouse over button several times.

Buttons and bg attached.

Images.rar

Link to comment
Share on other sites

What am I supposed to see on the button? Your PNG file for CloseA is corrupt btw.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

How it can be corrupted? Gosh.. Problem by problem.. I'm unlucky :)

Without $WS_EX_COMPOSITED button refresh sometime flick (u can see in that moment also default bg color of gui) and with it doesn't. About text, in both with and without $WS_EX_COMPOSITED its ok for you? With - Test text should be under TEST TEXT.

Edited by HeJake
Link to comment
Share on other sites

I only get that when you set the $WS_CLIPCHILDREN style, taking it out fixes that issue. I think part of the problem is that you're setting two buttons on top of each other rather than just changing the image.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Yes, i was thinking about that too, but didn't tested yet.

And whats about my second question at the beginning? About moving whole window by holding left mbutton (as usual)? Since there is no borders :)

Nah, its anyway flickering for me on change..

Edited by HeJake
Link to comment
Share on other sites

About window move, found $SC_DRAGMOVE.

About text, still no solution. Tried also to make gui transparent, so you wont see gui background on image change in case without using $WS_CLIPCHILDREN ( or guistate, and actually strange that you able to see it, if the gui covered by image ) but it didn't work ( still see the gui background on flickering, as well flickering itself :) )

Edited by HeJake
Link to comment
Share on other sites

search for FunSkin

it deals with the replacing of icons of the titlebar including close, minimize and maximize

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...