Jump to content

Scrolling a tab on a gui - Possible?


John117
 Share

Recommended Posts

I have a gui set up. It has several tabs.

On one of the tabs I need about 100 rows.

Each row includes 7 input fields.

As you can guess. I cant fit 100 rows on the gui without exceeding the gui size.

The gui is currently set at 800,600. I can see around 20 rows.

I need to somehow be able to scroll down on the tab to see the additional 80 tabs...

A scroll bar like in IE would be great!

Any suggestions?

test included. Thanks!

#include <GUIConstants.au3>
#include <TabConstants.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("{ESC}", "_ParentWin_Special_Close")
$Form1 = GUICreate("Form1", 800, 600, Default, Default)
$tab = GUICtrlCreateTab(10, 10, 780, 560, $TCS_BUTTONS)
$tab1 = GUICtrlCreateTabItem("tab1")
GUICtrlSetState(-1, $GUI_SHOW); will be display first
Dim $F[1000]
$aLeft = 20
$aTop = 150
$aHeigth = 20
$Rows = (1+(50*6)) ;rows = 50
For $x = 1 To $Rows Step 7
$F[$x] = GUICtrlCreateInput($x, 20, $aTop, 30, $aHeigth)
$F[$x+1] = GUICtrlCreateInput($x+1, 20+30+2, $aTop, 30, $aHeigth)
$F[$x+2] = GUICtrlCreateCombo($x+2, 20+30+30+4, $aTop, 120, $aHeigth)
$F[$x+3] = GUICtrlCreateInput($x+3, 20+30+30+120+6, $aTop, 300, $aHeigth)
$F[$x+4] = GUICtrlCreateCombo($x+4, 20+30+30+120+300+8, $aTop, 120, $aHeigth)
$F[$x+5] = GUICtrlCreateCombo($x+5, 20+30+30+120+300+120+10, $aTop, 40, $aHeigth)
$F[$x+6] = GUICtrlCreateCombo($x+6, 20+30+30+120+300+120+40+12, $aTop, 80, $aHeigth)
$aTop = $aTop + 22
Next
$tab2 = GUICtrlCreateTabItem("Tab2")
GUISetState(@SW_SHOW)
While 1
Sleep(20)
WEnd
Func _ParentWin_Special_Close()
Exit
EndFunc   ;==>_ParentWin_Special_Close
Link to comment
Share on other sites

  • Moderators

John117,

Try a child GUI with a scrollbar. ;)

The Tabs tutorial in the Wiki shows how to deal with child GUIs on tabs - the GUIScrollBars_Ex UDF in my sig will get you scrollbars in the child GUI very easily. Give it a try and come back if you run into difficulties. :)

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

Melba23: Thank you for your suggestion! Looks like it will be a good option.

I am stuck on how to automatically display the child gui and hide it when selecting another tab. Looks like it doesnt like 'onevent' for the individual tab selection.

Any thoughts on how to hide it, short of placing a button on the tab is should be on and having all tab selections hide it? (not really a bad option I guess)

#include <GUIConstants.au3>
#include <TabConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include "GUIScrollbars_Ex.au3"
Opt("GUIOnEventMode", 1)
HotKeySet("{ESC}", "_ParentWin_Special_Close")
$Form1 = GUICreate("Form1", 800, 600, Default, Default)
$tab = GUICtrlCreateTab(10, 10, 780, 560, $TCS_BUTTONS)
GUICtrlSetOnEvent(-1, "_Hide")
$tab1 = GUICtrlCreateTabItem("tab1")
;~ GUICtrlSetOnEvent(-1, "_Show")
GUICtrlSetState(-1, $GUI_SHOW); will be display first
$Left = 600
$Top = 40
$Heigth = 20
$Width = 120
Global $Report_Builder_Button = GUICtrlCreateButton("Click to Display", $Left, $Top, $Width, $Heigth, 0)
GUICtrlSetOnEvent(-1, "_Show")
$tab2 = GUICtrlCreateTabItem("Tab2")
;~ GUICtrlSetOnEvent(-1, "_Hide")
Dim $F[1000]
$aLeft = 20
$aTop = 150
$aHeigth = 20
$Rows = (1+(100*6)) ;rows = 50
; Close Tab definiton
GUICtrlCreateTabItem("")

$hTab_Win0 = GUICreate("", 780, 400, 10, 150, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
$aTop = 20
For $x = 1 To $Rows Step 7
$F[$x] = GUICtrlCreateInput($x, 20, $aTop, 30, $aHeigth)
$F[$x+1] = GUICtrlCreateInput($x+1, 20+30+2, $aTop, 30, $aHeigth)
$F[$x+2] = GUICtrlCreateCombo($x+2, 20+30+30+4, $aTop, 120, $aHeigth)
$F[$x+3] = GUICtrlCreateInput($x+3, 20+30+30+120+6, $aTop, 300, $aHeigth)
$F[$x+4] = GUICtrlCreateCombo($x+4, 20+30+30+120+300+8, $aTop, 120, $aHeigth)
$F[$x+5] = GUICtrlCreateCombo($x+5, 20+30+30+120+300+120+10, $aTop, 40, $aHeigth)
$F[$x+6] = GUICtrlCreateCombo($x+6, 20+30+30+120+300+120+40+12, $aTop, 80, $aHeigth)
$aTop = $aTop + 22
Next
_GUIScrollbars_Generate($hTab_Win0, 0, 2000)

GUISetState(@SW_SHOW, $Form1)
;~ GUISetState(@SW_SHOW, $hTab_Win0)

While 1
 Sleep(20)
WEnd
Func _Show()
GUISetState(@SW_SHOW, $hTab_Win0)
EndFunc
Func _Hide()
GUISetState(@SW_HIDE, $hTab_Win0)
EndFunc
Func _ParentWin_Special_Close()
;~  _GUIScrollbars_Generate($Form1, 0, 2000)
 Exit
EndFunc   ;==>_ParentWin_Special_Close
Link to comment
Share on other sites

  • Moderators

John117,

I would do it like this:

#include <GUIConstants.au3>
#include <TabConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include "GUIScrollbars_Ex.au3"

Opt("GUIOnEventMode", 1)

HotKeySet("{ESC}", "_Exit")

$Form1 = GUICreate("Form1", 800, 600, Default, Default)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$tab = GUICtrlCreateTab(10, 10, 780, 560, $TCS_BUTTONS)
GUICtrlSetOnEvent(-1, "_Tab")

$tab1 = GUICtrlCreateTabItem("tab1")
GUICtrlSetState(-1, $GUI_SHOW); will be display first
$Left = 600
$Top = 40
$Heigth = 20
$Width = 120

$tab2 = GUICtrlCreateTabItem("Tab2")
Dim $F[1000]
$aLeft = 20
$aTop = 150
$aHeigth = 20
$Rows = (1 + (100 * 6)) ;rows = 50

; Close Tab definiton
GUICtrlCreateTabItem("")

$hTab_Win0 = GUICreate("", 780, 400, 10, 150, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
GUISetBkColor(0xFF0000) ; Just to show the GUI clearly
$aTop = 20
For $x = 1 To $Rows Step 7
    $F[$x] = GUICtrlCreateInput($x, 20, $aTop, 30, $aHeigth)
    $F[$x + 1] = GUICtrlCreateInput($x + 1, 20 + 30 + 2, $aTop, 30, $aHeigth)
    $F[$x + 2] = GUICtrlCreateCombo($x + 2, 20 + 30 + 30 + 4, $aTop, 120, $aHeigth)
    $F[$x + 3] = GUICtrlCreateInput($x + 3, 20 + 30 + 30 + 120 + 6, $aTop, 300, $aHeigth)
    $F[$x + 4] = GUICtrlCreateCombo($x + 4, 20 + 30 + 30 + 120 + 300 + 8, $aTop, 120, $aHeigth)
    $F[$x + 5] = GUICtrlCreateCombo($x + 5, 20 + 30 + 30 + 120 + 300 + 120 + 10, $aTop, 40, $aHeigth)
    $F[$x + 6] = GUICtrlCreateCombo($x + 6, 20 + 30 + 30 + 120 + 300 + 120 + 40 + 12, $aTop, 80, $aHeigth)
    $aTop = $aTop + 22
Next
_GUIScrollbars_Generate($hTab_Win0, 0, 2000)

GUISetState(@SW_SHOW, $Form1)
GUISetState(@SW_SHOW, $hTab_Win0)

While 1
    Sleep(20)
WEnd

Func _Tab()

    Switch GUICtrlRead($tab)
        Case 0
            GUISetState(@SW_SHOW, $hTab_Win0)
        Case 1
            GUISetState(@SW_HIDE, $hTab_Win0)
    EndSwitch

EndFunc   ;==>_Tab

Func _Exit()
    Exit
EndFunc   ;==>_Exit

Please ask if anything is unclear. :)

Glad you like the Scrollbars UDF. ;)

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

$bShow = True
 
Func _ToggleWin()
    $bShow = Not $bShow
    If $bShow Then
        GUISetState(@SW_Show, $hTab_Win0)
        Return
    EndIf
    GUISetState(@SW_Hide, $hTab_Win0)
EndFunc

Also add event functions for the TAB not the TabItems using GUICtrlRead($Tab)

And you shouldn't have GUICtrlCreateTabItem("") where it is. Put it after the last control on that tab.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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

×
×
  • Create New...