Jump to content

Hide GUI controls before tab is switched?


Recommended Posts

I've a GUI with 3 tabs. The current code (irrelevant bits omitted) is as follows:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiIPAddress.au3>
#include <GUIListBox.au3>
#include <GuiRichEdit.au3>
#include <Misc.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

Global $g_hSAForm = GUICreate($g_sApplicationName, 801, 601, -1, -1)
Global $g_hSATabs = GUICtrlCreateTab(0, 0, 800, 600)

Global $g_hTestTabSheet = GUICtrlCreateTabItem("Tests")
Global $g_hStatusDisplayEdit = _GUICtrlRichEdit_Create($g_hSAForm, "", 9, 30, 782, 266, BitOR($ES_AUTOVSCROLL,$ES_READONLY,$WS_VSCROLL))

Global $g_hIpAddress = _GUICtrlIpAddress_Create($g_hSAForm, 172, 312, 130, 21)
_GUICtrlIpAddress_Set($g_hIpAddress, "0.0.0.0")

Global $g_hLogTabSheet = GUICtrlCreateTabItem("Log")
Global $g_hLogDispEdit = GUICtrlCreateEdit("", 9, 30, 782, 511, BitOR($ES_AUTOVSCROLL,$ES_READONLY,$WS_VSCROLL))
Global $g_hSettingsTabSheet = GUICtrlCreateTabItem("Settings")
Global $g_hSvcProfileSettingsEdit = GUICtrlCreateEdit("", 9, 46, 782, 201, BitOR($ES_AUTOVSCROLL,$ES_READONLY,$WS_VSCROLL))

GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($g_hStatusDisplayEdit)
            Exit

        Case $g_hSATabs
            Switch GUICtrlRead($g_hSATabs)
                Case 0
                    _GUICtrlIpAddress_ShowHide($g_hIpAddress, @SW_SHOW)
                    WinSetState($g_hStatusDisplayEdit, "", @SW_SHOW)

                Case Else
                    _GUICtrlIpAddress_ShowHide($g_hIpAddress, @SW_HIDE)
                    WinSetState($g_hStatusDisplayEdit, "", @SW_HIDE)
            EndSwitch
    EndSwitch
WEnd

The first tab contains a RichEdit and a IpAddress (among other GUI elements). Whenever I switch to and from the first tab, those two elements show/hide as intended, but there is a noticeable lag. As a result, for example, I can still see these elements after switching to the third tab for a split second before they disappear. I'm very certain system resource availability isn't an issue.

Is there a way to finish updating these two elements' visibility before the new tab selection is rendered?

Edited by thegreatjedi
Link to comment
Share on other sites

  • Moderators

thegreatjedi,

As suggested in the Tabs tutorial in the Wiki, I would use ControlShow/Hide like this:

Case $g_hSATabs
            Switch GUICtrlRead($g_hSATabs)
                Case 0
                    ControlShow($g_hSAForm, "", $g_hIpAddress)
                    ControlShow($g_hSAForm, "", $g_hStatusDisplayEdit)
                    ;_GUICtrlIpAddress_ShowHide($g_hIpAddress, @SW_SHOW)
                    ;WinSetState($g_hStatusDisplayEdit, "", @SW_SHOW)

                Case Else
                    ControlHide($g_hSAForm, "", $g_hIpAddress)
                    ControlHide($g_hSAForm, "", $g_hStatusDisplayEdit)
                    ;_GUICtrlIpAddress_ShowHide($g_hIpAddress, @SW_HIDE)
                    ;WinSetState($g_hStatusDisplayEdit, "", @SW_HIDE)
            EndSwitch

I get virtual instantaneous reaction from the 2 controls that way.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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