Jump to content

Replacing those ugly tab buttons with pictures.


Kickassjoe
 Share

Recommended Posts

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.

Link to comment
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.

Link to comment
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

Link to comment
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

Link to comment
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..
Link to comment
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()
Link to comment
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

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