Jump to content
nickpavini

Optimizing Tab Control - (Moved)

Recommended Posts

So I wrote this to simulate a program that would have a start and stop feature, and has a `tab design`. Right now there is a tab that has a `RichEdit` object intended to be a running log.

As you can see, after we "start" the program I put just some milliseconds of `sleep` to simulate running instructions. I created a function to check for requests that would be called on a larger scale randomly throughout code to ping the `GUI` per say.

   

#include <GUIConstantsEx.au3>
    #include <GuiRichEdit.au3>
    #include <WindowsConstants.au3>
    
    Global Const $h_numOfTabs = 2
    Global Enum $H_TAB_1, $H_TAB_2, $H_TAB_END
    Global $hGui, $h_logRichEdit, $iMsg,  $h_tabs, $h_startButton, $h_stopButton
    
    Example()
    
    Func Example()
        $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 400, 550, -1, -1)
    
        ; ADD START AND STOP BUTTONS
        $h_startButton = GUICtrlCreateButton( "Start", 50, 450 )
        $h_stopButton = GUICtrlCreateButton( "Stop", 150, 450 )
    
        $h_tabs = GUICtrlCreateTab( 5, 5, 390,375 )
    
        ; LOG TAB
        GUICtrlCreateTabItem( "Log" )
        $h_logRichEdit = _GUICtrlRichEdit_Create ( $hGui, "", 8, 30, 384, 347, BitOR( $ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY ) )
    
        ; STATS TAB
        GUICtrlCreateTabItem( "Stats" )
    
        ; Close TABS
        GUICtrlCreateTabItem( "" )
    
        GUISetState( @SW_SHOW ) ; initialize the gui
    
        While True
            CheckRequests()
        WEnd
    EndFunc   ;==>Example
    
    Func Start()
        while true
            Sleep(100)
            CheckRequests()
        WEnd
    EndFunc
    
    Func Stop()
    
    EndFunc
    
    Func CheckRequests()
        $iMsg = GUIGetMsg()
        while $iMsg <> 0
            Select
                Case $iMsg = $GUI_EVENT_CLOSE
                    _GUICtrlRichEdit_Destroy($h_logRichEdit) ; needed unless script crashes
                    ; GUIDelete()   ; is OK too
                    Exit
                Case $iMsg = $h_tabs
                    Switch GUICtrlRead( $h_tabs )
                        Case $H_TAB_1
                            ControlShow( $hGui, "", $h_logRichEdit )
                        Case Else
                            ControlHide( $hGui, "", $h_logRichEdit )
                    EndSwitch
                Case $iMsg = $h_startButton
                    Start()
                Case $iMsg = $h_stopButton
                    Stop()
            EndSelect
            $iMsg = GUIGetMsg()
        WEnd
    EndFunc

**At about 500ms sleep, the lag when switching tabs is visible.**

**My question:** On a larger scale, is this how we would handle/update things that are specific to a tab while running a larger program? If not, what would be a more efficient way of updating tab specific properties while running a larger overall program. 

I have also seen a design recently where all the tabs and related components were their own `GUI's` but I am not sure the relevance of everything being its own `GUI` and if it pertains to this question.

Any help or clarification is greatly appreciated, I am new to AutoIT and trying to figure out some do's and dont's as well as efficiency.

Share this post


Link to post
Share on other sites

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Share this post


Link to post
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

×
×
  • Create New...