Sign in to follow this  
Followers 0
Kickassjoe

Replacing those ugly tab buttons with pictures.

9 posts in this topic

#1 ·  Posted (edited)

Don't know if this has been posted before, but it wasn't, a while back when I needed it. Here it is!

#include <GUIConstants.au3>
Dim $TabSwitcher[2]

GUICreate("Test")

$TabSwitcher[0] = GUICtrlCreatePic("C:\WINDOWS\Coffee Bean.bmp", 10, 10,20,20)

$TabSwitcher[1] = GUICtrlCreatePic("C:\WINDOWS\Coffee Bean.bmp", 70, 10,20,20)

$tab = GUICtrlCreateTab(10,40, 200, 200);can be placed anywhere, doesnt matter, not visible

$tab1 = GUICtrlCreateTabItem("tab1")
GUICtrlCreateButton("button on tab 1", 10, 70)

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlCreateButton("button on tab 2", 10, 70)

GUICtrlSetState($tab, $GUI_HIDE)

GUISetState()

While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $TabSwitcher[0]
            If GUICtrlRead($tab) <> 0 Then GUICtrlSetState($tab1, $GUI_SHOW)
        Case $msg = $TabSwitcher[1]
            If GUICtrlRead($tab) <> 1 Then GUICtrlSetState($tab2, $GUI_SHOW)
        Case $msg = -3
            Exit
        Case Else
            
    EndSelect
WEnd
Edited by Kickassjoe

What goes around comes around... Payback's a bitch.

Share this post


Link to post
Share on other sites



Nice! I might try messing around with this for Multiple Desktops... Currently I do everything manually, like deleting every item that was in tab and then creating all the items that are supposed to be in the next tab. This could hopefully help with that...


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

It's Not working for me even after adding the missing "WEnd" I just get one button on a GUI. I am running XP SP2 with AI 3.2.10.0

Share this post


Link to post
Share on other sites

That would mean that the pictures aren't showing up, I have SP1, and those pictures are in the windows directory, on my C:\ drive, maybe your main drive isn't C:\? In any case, if you switch the directory of the $Tabswitcher pictures, the program should work fine.


What goes around comes around... Payback's a bitch.

Share this post


Link to post
Share on other sites

In my system this image named as Кофейня.bmp ;)

I think that this one is better to use on many systems:

@Systemdir & "\oobe\images\newbtm1.jpg"

But i like the idea of custom tabs :).


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

BTW, you can set icons for the tab item...

#include <GUIConstants.au3>

$hGUI = GUICreate("Tab With Image")


GUICtrlCreateTab(10, 10, 200, 200);, BitOr($GUI_SS_DEFAULT_TAB, $TCS_BUTTONS, $TCS_FOCUSNEVER))

$Tab1_Ctrl = _GUICtrlCreateTabItem(@Systemdir & "\shell32.dll", 25, " ")
GUICtrlCreateButton("Button on Tab 1", 20, 70)


$Tab2_Ctrl = _GUICtrlCreateTabItem(@Systemdir & "\shell32.dll", 14, " ")
GUICtrlCreateButton("Button on Tab 2", 20, 70)

GUICtrlCreateTabItem("")

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _GUICtrlCreateTabItem($sFileName, $iIcon_Name, $sTabItem_Text=" ")
    Local $nRet_Ctrl = GUICtrlCreateTabItem($sTabItem_Text)
    GUICtrlSetImage(-1, $sFileName, $iIcon_Name)
    
    Return $nRet_Ctrl
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

BTW, you can set icons for the tab item...

#include <GUIConstants.au3>

$hGUI = GUICreate("Tab With Image")


GUICtrlCreateTab(10, 10, 200, 200);, BitOr($GUI_SS_DEFAULT_TAB, $TCS_BUTTONS, $TCS_FOCUSNEVER))

$Tab1_Ctrl = _GUICtrlCreateTabItem(@Systemdir & "\shell32.dll", 25, " ")
GUICtrlCreateButton("Button on Tab 1", 20, 70)


$Tab2_Ctrl = _GUICtrlCreateTabItem(@Systemdir & "\shell32.dll", 14, " ")
GUICtrlCreateButton("Button on Tab 2", 20, 70)

GUICtrlCreateTabItem("")

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _GUICtrlCreateTabItem($sFileName, $iIcon_Name, $sTabItem_Text=" ")
    Local $nRet_Ctrl = GUICtrlCreateTabItem($sTabItem_Text)
    GUICtrlSetImage(-1, $sFileName, $iIcon_Name)
    
    Return $nRet_Ctrl
EndFunc
Ahhh, This one works..

Share this post


Link to post
Share on other sites

Excellent!

Play around with this and you can come up with some neat stuff..

Heres one using labels..

#include <GUIConstants.au3>
Dim $TabSwitcher[2]

GUICreate("Test")

$TabSwitcher[0] = GUICtrlCreateLabel("Tab One", 10, 10,60,20, $SS_SUNKEN +$SS_CENTER+ $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, 0xf0f0f0)
GUICtrlSetColor(-1, 0x000000)

$TabSwitcher[1] = GUICtrlCreateLabel("Tab Two", 72, 10,60,20, $SS_SUNKEN +$SS_CENTER+ $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, 0xc0c0c0)
GUICtrlSetColor(-1, 0x000000)

$tab = GUICtrlCreateTab(10,40, 200, 200);can be placed anywhere, doesnt matter, not visible

$tab1 = GUICtrlCreateTabItem("tab1")
GUICtrlCreateButton("button on tab 1", 10, 70)

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlCreateButton("button on tab 2", 10, 70)

GUICtrlSetState($tab, $GUI_HIDE)

GUISetState()

While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $TabSwitcher[0]
            If GUICtrlRead($tab) <> 0 Then GUICtrlSetState($tab1, $GUI_SHOW)
                GUICtrlSetBkColor($TabSwitcher[0], 0xf0f0f0)
                GUICtrlSetColor($TabSwitcher[0], 0x000000)
                GUICtrlSetBkColor($TabSwitcher[1], 0xc0c0c0)
                GUICtrlSetColor($TabSwitcher[1], 0x000000)
                
        Case $msg = $TabSwitcher[1]
            If GUICtrlRead($tab) <> 1 Then GUICtrlSetState($tab2, $GUI_SHOW)
                GUICtrlSetBkColor($TabSwitcher[0], 0xc0c0c0)
                GUICtrlSetColor($TabSwitcher[0], 0x000000)
                GUICtrlSetBkColor($TabSwitcher[1], 0xf0f0f0)
                GUICtrlSetColor($TabSwitcher[1], 0x000000)
        Case $msg = -3
            Exit
        Case Else
            
    EndSelect
WEnd

Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

Nice mrRevoked! i like this :)

About the checking the current tab part.. it's better to check for all controls:

......

   Select
        Case $msg = $TabSwitcher[0]
            If GUICtrlRead($tab, 1) = $tab1 Then ContinueLoop ;To prevent the flickering and second state set.
            
            GUICtrlSetState($tab1, $GUI_SHOW)
            GUICtrlSetBkColor($TabSwitcher[0], 0xf0f0f0)
            GUICtrlSetColor($TabSwitcher[0], 0x000000)
            GUICtrlSetBkColor($TabSwitcher[1], 0xc0c0c0)
            GUICtrlSetColor($TabSwitcher[1], 0x000000)
                
        Case $msg = $TabSwitcher[1]
            If GUICtrlRead($tab, 1) = $tab2 Then ContinueLoop ;To prevent the flickering and second state set.
            
            GUICtrlSetState($tab2, $GUI_SHOW)
            GUICtrlSetBkColor($TabSwitcher[0], 0xc0c0c0)
            GUICtrlSetColor($TabSwitcher[0], 0x000000)
            GUICtrlSetBkColor($TabSwitcher[1], 0xf0f0f0)
            GUICtrlSetColor($TabSwitcher[1], 0x000000)
        Case $msg = -3
            Exit
        Case Else
            
    EndSelect

...

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt 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
Sign in to follow this  
Followers 0