Jump to content

GUI blinks on button clicks


Recommended Posts

#include <GUIConstantsEx.au3>

Global $tab[6], $button[6]

Main()

Func Main()
$MainGUI = GUICreate("Main", 645, 568)
GUISetBkColor(0xFFFFFF)
GUICtrlCreatePic(@ScriptDir & "\img_bg_gray.bmp", 0, 0, 645, 568)
GUICtrlSetState(-1, $GUI_DISABLE)

$tabpane = GUICtrlCreateTab(10, 10, 200, 100)

$tab[0] = GUICtrlCreateTabItem("tab1")
$Label0 = GUICtrlCreateLabel("Summary1", 320, 110, 209, 24)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")

$tab[1] = GUICtrlCreateTabItem("tab2")
$Label1 = GUICtrlCreateLabel("Summary2", 320, 110, 209, 24)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")

$tab[2] = GUICtrlCreateTabItem("tab3")
$Label2 = GUICtrlCreateLabel("Summary3", 320, 110, 209, 24)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")

$tab[3] = GUICtrlCreateTabItem("tab4")
$Label3 = GUICtrlCreateLabel("Summary4", 320, 110, 209, 24)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")

$tab[4] = GUICtrlCreateTabItem("tab5")
$Label4 = GUICtrlCreateLabel("Summary5", 320, 110, 209, 24)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")

$tab[5] = GUICtrlCreateTabItem("tab6")
$Label5 = GUICtrlCreateLabel("Summary6", 320, 110, 209, 24)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")

GUICtrlCreateTabItem("") ; end tabitem definition

$button[0] = GUICtrlCreateButton("Tab 1", 15, 20, 130, 39)
$button[1] = GUICtrlCreateButton("Tab 2", 15, 60, 130, 39)
$button[2] = GUICtrlCreateButton("Tab 3", 15, 100, 130, 39)
$button[3] = GUICtrlCreateButton("Tab 4", 15, 140, 130, 39)
$button[4] = GUICtrlCreateButton("Tab 5", 15, 180, 130, 39)
$button[5] = GUICtrlCreateButton("Tab 6", 15, 220, 130, 39)

GUICtrlSetState($tabpane, $GUI_HIDE) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $button[0]
GUICtrlSetState($tab[0], $GUI_SHOW)
Case $button[1]
GUICtrlSetState($tab[1], $GUI_SHOW)
Case $button[2]
GUICtrlSetState($tab[2], $GUI_SHOW)
Case $button[3]
GUICtrlSetState($tab[3], $GUI_SHOW)
Case $button[4]
GUICtrlSetState($tab[4], $GUI_SHOW)
Case $button[5]
GUICtrlSetState($tab[5], $GUI_SHOW)
EndSwitch
WEnd
EndFunc ;==>Main

Hi All

Hoping someone is able to assit.

I have a GUI with a background bitmap, the buttons are associated with tabs.

Without the background bitmap it works fine, but with it, it blinks everytime I press a button.

Hopefully its something very simple!

Edited by Iceman682
Link to comment
Share on other sites

I have shortened your code with loops

and added $WS_EX_COMPOSITED exstyle this would solve your problem for the time being

this exstyle has its own demerits use with caution

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

Global $tab[6], $button[6]

Main()

Func Main()
$MainGUI = GUICreate("Main", 645, 568, -1, -1, -1, $WS_EX_COMPOSITED)
GUISetFont( 16, 800, 0, "Arial")
GUICtrlCreatePic("x.jpg", 0, 0, 645, 568)
GUICtrlSetState(-1, $GUI_DISABLE)

Local $tabpane = GUICtrlCreateTab(10, 10, 200, 100),$tab[6]
GUICtrlSetState(-1, $GUI_HIDE )

For $i = 0 To 5
$tab[$i] = GUICtrlCreateTabItem("tab1")
GUICtrlCreateLabel("Summary" & $i + 1, 320, 110, 209, 24) ;Use Assign if $Label0 is required
GUICtrlSetState(-1, $GUI_ONTOP )
Next
GUICtrlCreateTabItem("") ; end tabitem definition

For $i = 0 To 5
$button[$i] = GUICtrlCreateButton("Tab " & $i + 1, 15, ($i+1)*42, 130, 39)
GUICtrlSetState(-1, $GUI_ONTOP )
Next

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $button[0] To $button[5]
GUICtrlSetState($tab[$msg - $button[0]], $GUI_SHOW)
EndSwitch
WEnd
EndFunc   ;==>Main

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

Many thanks for the rapid response and for shortening my code.

Unfortunatley I'm unable to use the shortened version as I'm using images as buttons

Thanks anyway for your very kind thought.

As for the exstyle, I just hope it doesn't effect the remaining code that I will now insert ;)

Link to comment
Share on other sites

I recommend to use loops,

for different images makes an array and they set the values looping through the array

It makes code reading very easy

regards

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

Unfortunately I'm not clever enough to figure that one out

It comes with time and energy in willing to learn, not about intelligence. Everyone has the ability to learn.

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

I agree with guinness

A simple example could be as follows

Local $File[3] = ["h.jpg", "y.jpg", "p.jpg"]

;.... The example
For $i = 0 To 2
GUICtrlCreatePic( $File[ $i ], 10, $i * 20 )
Next
;..... == Hope this helps
Edited by PhoenixXL

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...