Jump to content

How to create a tab switcher with images


Recommended Posts

I don't know if you've ever used rainlendar before but I have a question about how it doe sosmething.

In the options window they have what seems to be an image in a row at the top like in the picture below:

and everytime I click on different sections of it it simulates a tab item and it switches to a different tab.

My question is how to do this like rainlendar does it. I don't want to use tabs, I want to copy what it does because I have a much better looking image than regular tabs. A lot of programs do this, but I can only think of this one.

Look at the picture to to understand what I mean.

Link to comment
Share on other sites

I think it is a GUI like this:

-ParentGUI with Image-Buttons to change "tabs"

-some child GUIs which hold the controls for the Tabs and get hidden shown

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Right. Example:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Global $OptionPages[5][2]; 5 Pages , for each page button + GUI

#region - GUI Create
$parent = GUICreate('PArent',200,240)
$OptionPages[0][0] = GUICtrlCreateButton("1",10,10,30,30)
$OptionPages[1][0] = GUICtrlCreateButton("2",50,10,30,30)
$OptionPages[2][0] = GUICtrlCreateButton("3",90,10,30,30)
$OptionPages[3][0] = GUICtrlCreateButton("4",130,10,30,30)
$OptionPages[4][0] = GUICtrlCreateButton("5",170,10,30,30)

$OptionPages[0][1] = GUICreate("Option1",200,200,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0xFFFFFF)
GUICtrlCreateLabel("hallo",10,10)

$OptionPages[1][1] = GUICreate("Option2",200,200,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0xFFFF00)
GUICtrlCreateEdit("kjkkkk",10,40)

$OptionPages[2][1] = GUICreate("Option3",200,200,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0x00FFFF)

$OptionPages[3][1] = GUICreate("Option4",200,200,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0x000000)

$OptionPages[4][1] = GUICreate("Option5",200,200,0,40,$WS_CHILD,0,$parent)
GUISetBkColor(0xFF0000)

GUISwitch($parent)
GUISetState()
#endregion

#region - GUI SelectLoop
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case Else
            $newpage = _CheckOptionPages($msg)
            If $newpage Then ConsoleWrite($newpage & @CRLF)
    EndSelect
WEnd
#endregion

Func _CheckOptionPages($msg)
    For $i = 0 To UBound($OptionPages)-1
        If $msg = $OptionPages[$i][0] And BitAND(WinGetState($OptionPages[$i][1]),2) <> 2 Then
            Return _SwitchToPage($i)
            ExitLoop
        EndIf
    Next
EndFunc
Func _SwitchToPage($page)
    If $page >= UBound($OptionPages) Then Return SetError(1,0,0)
    For $i = 0 To UBound($OptionPages)-1
        GUISetState(@SW_HIDE,$OptionPages[$i][1])
    Next
    GUISetState(@SW_SHOW,$OptionPages[$page][1])
    Return $page+1
EndFunc
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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