LarsJ

Tab control example: Tabs and subtabs on demand

15 posts in this topic

#1 ·  Posted (edited)

Create tab items and subtabs dynamically.

The tabs and subtabs are managed by a tree structure implemented as a treeview control.

  • Add tab items and subtabs
  • Resizable window
  • Rename tab items
  • Drag and drop support
  • Cut, copy (once), paste (many)
  • Save to and read from inifile
23 December 2011

Added an option to the context menu to set the spacing between the tab controls. The zipfile below is updated.

19 December 2011

Drag and drop

You can drag a tab item (tab header) and drop it on another tab item. An item is dropped under the mouse cursor moving the item you are dropping on to the left or right. You can't drop an item on one of it's own subtabs. That means that you can drag sidewards and upwards but not downwards. When you click a tab item you can't drag until the item is updated (when you see the dotted rectangle around the text).

TabExDemo.au3 is a demo program. It shows how the tabs and subtabs are managed by the tree structure in the treeview control.

TabExEdit.au3 is an example with an edit control. For tab items with an even number (name) the edit control is initially set to the number.

TabExList.au3 is an example with a listview (includes WinAPIEx.au3).

TabExEmpty.au3 has an empty window with no data. It can be used as a starting point for applications.

TabExFunc.au3 is common functions (includes APIConstants.au3).

This is a zipfile with the scripts.

TabEx.zip

LarsJ

Edited by LarsJ
2 people like this

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Does this require the autoit beta or stable version?

Because using the stable version, I am getting the following in my output:

H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(140,27) : WARNING: $VK_SHIFT: possibly used before declaration.
    ElseIf $mKey = $VK_SHIFT Then
    ~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(610,18) : WARNING: $fRenTabItem: possibly used before declaration.
    If $fRenTabItem =
    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1205,31) : WARNING: $VK_SHIFTs: possibly used before declaration.
        Case _IsPressed( $VK_SHIFTs )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1207,33) : WARNING: $VK_CONTROLs: possibly used before declaration.
        Case _IsPressed( $VK_CONTROLs )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1208,23) : WARNING: $VK_CONTROL: possibly used before declaration.
            $mKey = $VK_CONTROL
            ~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1213,40) : WARNING: $VK_TABs: possibly used before declaration.
        Case $fKey  And _IsPressed( $VK_TABs )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1215,19) : WARNING: $VK_TAB: possibly used before declaration.
            $vKey = $VK_TAB
            ~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1217,43) : WARNING: $VK_DELETEs: possibly used before declaration.
        Case $fKey  And _IsPressed( $VK_DELETEs )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1219,22) : WARNING: $VK_DELETE: possibly used before declaration.
            $vKey = $VK_DELETE
            ~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1221,39) : WARNING: $VK_F2s: possibly used before declaration.
        Case $fKey  And _IsPressed( $VK_F2s )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1223,18) : WARNING: $VK_F2: possibly used before declaration.
            $vKey = $VK_F2
            ~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1225,39) : WARNING: $VK_F5s: possibly used before declaration.
        Case $fKey  And _IsPressed( $VK_F5s )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1227,18) : WARNING: $VK_F5: possibly used before declaration.
            $vKey = $VK_F5
            ~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1229,39) : WARNING: $VK_F6s: possibly used before declaration.
        Case $fKey  And _IsPressed( $VK_F6s )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1231,18) : WARNING: $VK_F6: possibly used before declaration.
            $vKey = $VK_F6
            ~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1233,39) : WARNING: $VK_F7s: possibly used before declaration.
        Case $fKey  And _IsPressed( $VK_F7s )
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(1235,18) : WARNING: $VK_F7: possibly used before declaration.
            $vKey = $VK_F7
            ~~~~~~~~~~~~~~^
H:PortableAppsAutoITPortableAppIncludemisc.au3(641,48) : ERROR: _IsPressed() already defined.
Func _IsPressed($sHexKey, $vDLL = 'user32.dll')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(170,22) : WARNING: $cmDataWin0: possibly used before declaration.
                    Case $cmDataWin0
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(173,22) : WARNING: $cmDataWin1: possibly used before declaration.
                    Case $cmDataWin1
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(176,22) : WARNING: $cmDataWin2: possibly used before declaration.
                    Case $cmDataWin2
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(179,22) : WARNING: $cmDataWin3: possibly used before declaration.
                    Case $cmDataWin3
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(182,22) : WARNING: $cmDataWin4: possibly used before declaration.
                    Case $cmDataWin4
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(185,22) : WARNING: $cmDataWin5: possibly used before declaration.
                    Case $cmDataWin5
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(188,22) : WARNING: $cmDataWin6: possibly used before declaration.
                    Case $cmDataWin6
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(191,22) : WARNING: $cmDataWin7: possibly used before declaration.
                    Case $cmDataWin7
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(193,22) : WARNING: $cmDataWin8: possibly used before declaration.
                    Case $cmDataWin8
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(196,22) : WARNING: $cmDataWin9: possibly used before declaration.
                    Case $cmDataWin9
                    ~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(198,23) : WARNING: $cmDataWin10: possibly used before declaration.
                    Case $cmDataWin10
                    ~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(200,23) : WARNING: $cmDataWin11: possibly used before declaration.
                    Case $cmDataWin11
                    ~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(634,21) : WARNING: $fAddXItemsTabs: possibly used before declaration.
    If $fAddXItemsTabs =
    ~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3(1257,43) : WARNING: $idTabCtrlButton: possibly used before declaration.
    ControlShow( $hGui, "", $idTabCtrlButton )
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExFunc.au3(140,27) : ERROR: $VK_SHIFT: undeclared global variable.
    ElseIf $mKey = $VK_SHIFT Then
    ~~~~~~~~~~~~~~~~~~~~~~~~~^
H:DocumentsOther DocumentsScriptsTabsExTabExDemo.au3 - 2 error(s), 31 warning(s)

Or is it incorrect includes?

This is while trying to run TabEXDemo. All supplied files are in the same directory.

Edited by Melba23
Amended code tags

Share this post


Link to post
Share on other sites

Mikeman27294,

It is [code][/code], not [text][/text], :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Ok, thanks.

Share this post


Link to post
Share on other sites

Hi Mikeman27294,

Do you still get errors? I have just tried to download the zipfile from the site. I just unpack all files in the same directory, doubleclick TabExDemo.au3 and it runs. I have not compiled to exe, but the exe runs fine too (at least on my PC which is XP SP3).

I use version v3.3.6.1 which I think is the stable version. And I use APIConstants.au3 and WinAPIEx.au3 dated 2011-10-20 which I also think is the latest version.

The Virtual Key Codes are defined in APIConstants.au3 (do you have this file) which is included in TabExFunc.au3. And TabExFunc.au3 is included in TabExDemo.au3. So I don't understand the warnings about the Virtual Key Codes.

$fRenTabItem is declared as a global variable the first time you rename a tab item.

I have copied _IsPressed from Misc.au3 to TabExFunc.au3. And I have not included Misc.au3.

LarsJ

Share this post


Link to post
Share on other sites

Hi Mikeman27294,

Now I understand, you get the errors and warnings from the syntax checker Au3Check.exe, which I have used for the first time 5 minutes ago.

The warnings about the Virtual Key Codes and the error about $VK_SHIFT is probably because of a missing

APIConstants.au3. You can get it from Put the au3-files WinAPIEx.au3, APIErrors.au3 and APIConstants.au3 in the include folder.

As mentioned I have copied _IsPressed() from Misc.au3 to TabExFunc.au3. And I have not included Misc.au3. When I use Au3Check.exe, I don't get an error about _IsPressed(). I don't understand why you get an error on this function.

When I use Au3Check.exe I get 24 warnings which all is because of global variables not defined in the top of the script but only at the time they are used or in some kind of initialisation function. That should not prevent the program from running.

LarsJ

Share this post


Link to post
Share on other sites

Lars,

your udf looks very clever.

The following are only small points.

The tab within a tab in your example is a bit too tight a fit and it's difficult to see which is the outer and which is the inner tab.

When I choose "make 2 tabs" it deletes any tabs already created.

Make 10 sub tabs cretaes only 9 sub tabs.

This is a major point. Your script needs to be reorganised IMO so that it will run. If you use a global variable in a function it doesn't make sense to me to have it declared as global in another function. That causes errors unecessarrily. Why not declare a global variable in global space before any other functions?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Martin,

First of all I want to stress that this is only examples. There is much to do to make the examples to real applications.

To your points.

May be the spacing between the tab controls is too small and should have been larger.

"Make 2 tabs" deletes any tabs already created.

It certainly does. When I started working on these examples I used a lot of time creating tab items and sub tabs and recreating the same structure several times. So I made these "Make"-functions to create some tabs in a hurry. They should be used the opposite way around. Start with the "Make"-functions and then add some tab items and sub tabs.

"Make 10 sub tabs" creates only 9 sub tabs.

You are right. The first tab control is not a sub tab.

The global variables.

You are absolutely right and I apologize for the errors.

Lars

Share this post


Link to post
Share on other sites

Added an option to the context menu to set the spacing between the tab controls. Moved some globals to the top of the scripts, so that they can pass the Au3Check test. I was not aware of this function. I apologize for that. The zipfile in the first post is updated.

LarsJ

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Woah... I forgot all about this thread.

Sorry, I had APIConstants and WinAPIEx already. I will take another look though, see if I get the errors again and if so, if I can fix it.

EDIT

Nope. There are still constants declared twice and if I use IsPressed the script still crashes. When I remove the include, it errors saying that variables that were declared in the script don't exist.

Edited by Mikeman27294

Share this post


Link to post
Share on other sites

Mikeman27294,

I have just downloaded the files and tested the scripts with a complete new installation of 3.3.6.1 with the include files from WinAPIEx_3.6_3361.zip and tested the scripts with a complete new installation of 3.3.8.0 with the include files from WinAPIEx_3.6_3380.zip. I get no errors at all.

I have no explanation on your errors.

This is the output in SciTE from TabExDemo.au3 tested on 3.3.8.0:

>"E:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\WINDOWS\Temp\Dwnld\Autoit\TabExDemo.au3" /UserParams

+>12:49:03 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0409 Keyboard:00000406 OS:WIN_XP/Service Pack 3 CPU:X64 OS:X86)

>Running AU3Check (1.54.22.0) from:E:\Program Files\AutoIt3

+>12:49:03 AU3Check ended.rc:0

>Running:(3.3.8.0):E:\Program Files\AutoIt3\autoit3.exe "C:\WINDOWS\Temp\Dwnld\Autoit\TabExDemo.au3"

+>12:49:48 AutoIT3.exe ended.rc:0

>Exit code: 0 Time: 46.815

Share this post


Link to post
Share on other sites

I had the same warnings for $vk_shift and the rest. I downloaded winapiex and copied the three files to the Include directory and then everything worked ok. For whatever reason, all of the $vk constants were commented out in the version that I was using.

Share this post


Link to post
Share on other sites

@LarsJ This is awesome.
Could you please add this to your signature ?

Thanks for sharing @LarsJ "The WinGUI magician" ;)

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

This. Changes. Everything.  I've been looking for a way to dynamically create tabs for a long time.  Now I can complete my version of GUIBuilder that I'm currently experimenting with.  Thanks for necroing this thread MLipok!

Edited by jaberwacky

Share this post


Link to post
Share on other sites
1 hour ago, jaberwacky said:

Now I can complete my version of GUIBuilder that I'm currently experimenting with

This is awesome news @jaberwacky

1 hour ago, jaberwacky said:

Thanks for necroing this thread MLipok!

You're welcome.

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

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

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

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