Jump to content

Recommended Posts

Posted

If you run the code below which is an example I found in the helpfile you'll notice there is a rectangle shaped area extending horizontally along the top of the tab. It's a blank brownish space where another tab item would go.

My question is how to change this to match the background color of the window.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $tab, $tab0, $tab0OK, $tab0input
    Local $tab1, $tab1combo, $tab1OK
    Local $tab2, $tab2OK, $msg
    
    GUICreate("My GUI Tab", 250, 150); will create a dialog box that when displayed is centered

    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)

    $tab = GUICtrlCreateTab(10, 10, 200, 100)

    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab0OK = GUICtrlCreateButton("OK0", 20, 50, 50, 20)
    $tab0input = GUICtrlCreateInput("default", 80, 50, 70, 20)

    $tab1 = GUICtrlCreateTabItem("tab----1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab1combo = GUICtrlCreateCombo("", 20, 50, 60, 120)
    GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon"); default Jon
    $tab1OK = GUICtrlCreateButton("OK1", 80, 50, 50, 20)

    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW); will be display first
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    $tab2OK = GUICtrlCreateButton("OK2", 140, 50, 50)

    GUICtrlCreateTabItem(""); end tabitem definition

    GUICtrlCreateLabel("Click on tab and see the title", 20, 130, 250, 20)

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $tab Then
            ; display the clicked tab
            WinSetTitle("My GUI Tab", "", "My GUI Tab" & GUICtrlRead($tab))
        EndIf
    WEnd
EndFunc   ;==>Example
Posted (edited)

There is a few workarounds, one is create the tabs justified:

.....
    GUICreate("My GUI Tab", 250, 150); will create a dialog box that when displayed is centered
    
    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)
    
    $tab = GUICtrlCreateTab(10, 10, 200, 100, $GUI_SS_DEFAULT_TAB+$TCS_FIXEDWIDTH)
    GUICtrlSendMsg($tab, $TCM_SETITEMSIZE, 0, BitAND(65, 0xFFFF) + BitShift(BitAND(15, 0xFFFF), -16))
....

P.S

Needs the #include <TabConstants.au3>.

Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

Or you just draw some label with color on the area that you need to cover:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $tab, $tab0, $tab0OK, $tab0input
    Local $tab1, $tab1combo, $tab1OK
    Local $tab2, $tab2OK, $msg
    
    GUICreate("My GUI Tab", 250, 150); will create a dialog box that when displayed is centered
    
    GUISetBkColor(0x00E0FFFF)
    ;GUISetFont(9, 300)
    
    $tab = GUICtrlCreateTab(10, 10, 200, 100)
    
    $tab0 = GUICtrlCreateTabItem("tab0")
    GUICtrlCreateLabel("label0", 30, 80, 50, 20)
    $tab0OK = GUICtrlCreateButton("OK0", 20, 50, 50, 20)
    $tab0input = GUICtrlCreateInput("default", 80, 50, 70, 20)

    $tab1 = GUICtrlCreateTabItem("tab----1")
    GUICtrlCreateLabel("label1", 30, 80, 50, 20)
    $tab1combo = GUICtrlCreateCombo("", 20, 50, 60, 120)
    GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon"); default Jon
    $tab1OK = GUICtrlCreateButton("OK1", 80, 50, 50, 20)

    $tab2 = GUICtrlCreateTabItem("tab2")
    GUICtrlSetState(-1, $GUI_SHOW); will be display first
    GUICtrlCreateLabel("label2", 30, 80, 50, 20)
    $tab2OK = GUICtrlCreateButton("OK2", 140, 50, 50)

    GUICtrlCreateTabItem(""); end tabitem definition
    
    GUICtrlCreateLabel("", 147, 10, 200, 20)
    GUICtrlSetBkColor(-1, 0x00E0FFFF)
    
    GUICtrlCreateLabel("Click on tab and see the title", 20, 130, 250, 20)

    GUISetState()
    
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        If $msg = $tab Then
            ; display the clicked tab
            WinSetTitle("My GUI Tab", "", "My GUI Tab" & GUICtrlRead($tab))
        EndIf
    WEnd
EndFunc   ;==>Example

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

And here is an example with UDF usage:

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <GUITab.au3>

$hGUI = GUICreate("_GUICtrlTab_CoverBackground - Demo!", 250, 150); will create a dialog box that when displayed is centered
GUISetBkColor(0x00E0FFFF)

$MainTab = GUICtrlCreateTab(10, 10, 230, 120)

$TabItem1 = GUICtrlCreateTabItem("Tab1")
$TabItem2 = GUICtrlCreateTabItem("Tab2")
$TabItem3 = GUICtrlCreateTabItem("Tab3")

GUICtrlCreateTabItem(""); End tabitem definition

$Status_Label = GUICtrlCreateLabel("Current Tab: 1", 20, 130, 250, 20)

_GUICtrlTab_CoverBackground($hGUI, $MainTab, 0x00E0FFFF)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MainTab
            GUICtrlSetData($Status_Label, "Current Tab: " & GUICtrlRead($MainTab)+1)
    EndSwitch
WEnd

Func _GUICtrlTab_CoverBackground($hWnd, $hTab, $nColor)
    If Not IsHWnd($hTab) Then $hTab = GUICtrlGetHandle($hTab)
    
    Local $iLastIndex = _GUICtrlTab_GetItemCount($hTab)
    Local $tRect = _GUICtrlTab_GetItemRectEx($hTab, $iLastIndex-1)
    
    Local $aTabPos = ControlGetPos($hWnd, "", $hTab)
    
    Local $iLeft = DllStructGetData($tRect, "Right")
    Local $iBottom = DllStructGetData($tRect, "Bottom")
    
    GUICtrlCreateLabel("", $iLeft + $aTabPos[0] + 2, $aTabPos[1], $aTabPos[2]-$iLeft-2, $iBottom)
    GUICtrlSetBkColor(-1, $nColor)
EndFunc

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  Quote

it didn't change the header color.

It's not supose to ;)

Check my last post to see the solution.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

I did and I've tried a label before and even with it you can still see some brownish area around the tab items. It'll take something more than a label to hide everything

Posted
  Quote

So is label the only way to do it?

I guess that any static control will do (Graphic for example) ;)

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  IWantIt said:

So is label the only way to do it?

This is the solution I suggested to you when you asked about the same thing a few months ago. Can you look at the result and tell me if it's what you want?

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$LastTheme = XPStyle()
$Tab1 = GUICtrlCreateTab(184, 88, 289, 193)
XPStyle($LastTheme)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Button3 = GUICtrlCreateButton("Button3", 280, 176, 75, 25, 0)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Button2 = GUICtrlCreateButton("Button2", 280, 176, 75, 25, 0)
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$Button1 = GUICtrlCreateButton("Button1", 280, 176, 75, 25, 0)
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd




;XPStyle turns XP theme on or off
;Param $theme - 0 turns XP theme off
;              if an array then the theme is set using the array
;Returns        an array defining the last XP theme
Func XPStyle($theme = 0)
    If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0
    
    If $theme = 0 Or Not IsArray($theme) Then
       $theme = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return $theme
    ElseIf IsArray($theme) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $theme[0])
        Return $theme
    EndIf
    Return 0
EndFunc
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.
Posted (edited)

martin:

you still dont understand what im after.

check this code out.

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
GUISetBkColor(0xFFFFFF, $Form1)
$LastTheme = XPStyle()
$Tab1 = GUICtrlCreateTab(184, 88, 289, 193)
XPStyle($LastTheme)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Button3 = GUICtrlCreateButton("Button3", 280, 176, 75, 25, 0)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Button2 = GUICtrlCreateButton("Button2", 280, 176, 75, 25, 0)
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$Button1 = GUICtrlCreateButton("Button1", 280, 176, 75, 25, 0)
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd




;XPStyle turns XP theme on or off
;Param $theme - 0 turns XP theme off
;               if an array then the theme is set using the array
;Returns        an array defining the last XP theme
Func XPStyle($theme = 0)
    If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0
    
    If $theme = 0 Or Not IsArray($theme) Then
       $theme = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return $theme
    ElseIf IsArray($theme) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $theme[0])
        Return $theme
    EndIf
    Return 0
EndFunc

since the bk color is white now you can see the brown tab header color, which i dont want. i dont know what the point of turning off and on the xp themes were.

Edited by IWantIt
Posted

@martin

The problem is in the tab header area, we can not change the background color there (in correct way).

Just add GUISetBkColor(0x0) after GuiCreate() line, and you will see the problem...

Here is a screenshot:

Posted Image

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  IWantIt said:

martin:

you still dont understand what im after.

check this code out.

.

.

.

since the bk color is white now you can see the brown tab header color, which i dont want. i dont know what the point of turning off and on the xp themes were.

I am a bit lost with your statements.

There is no brown line anymore when I run that code and that was the point of turning off XP themes.

If you mean you don't want the area at the top right to be a different colour to the background then MrCreatoR has already given you more than one solution to that.

Like this for example

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
GUISetBkColor(0xFFFFFF, $Form1)
$LastTheme = XPStyle()
$Tab1 = GUICtrlCreateTab(184, 88, 289, 193)
XPStyle($LastTheme)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Button3 = GUICtrlCreateButton("Button3", 280, 176, 75, 25, 0)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$Button2 = GUICtrlCreateButton("Button2", 280, 176, 75, 25, 0)
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$Button1 = GUICtrlCreateButton("Button1", 280, 176, 75, 25, 0)
GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlCreateTabItem("")
guictrlcreatelabel("",380,88,100,21)
GUICtrlSetBkColor(-1,0xffffff)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd




;XPStyle turns XP theme on or off
;Param $theme - 0 turns XP theme off
;              if an array then the theme is set using the array
;Returns        an array defining the last XP theme
Func XPStyle($theme = 0)
    If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0
    
    If $theme = 0 Or Not IsArray($theme) Then
       $theme = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
        Return $theme
    ElseIf IsArray($theme) Then
        DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $theme[0])
        Return $theme
    EndIf
    Return 0
EndFunc
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.
Posted

ok.....

i just wish there was a better way. even using the labels if the first or second tab item is selected the little "brown stuff" still shows a little bit.

Posted

  IWantIt said:

ok.....

i just wish there was a better way. even using the labels if the first or second tab item is selected the little "brown stuff" still shows a little bit.

I don't know what the "brown stuff" is, but if you mean that the label needs to be moved depending on the tab selected then I agree. There is also a small border around certain tabs and it is difficult to get rid of that.
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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...