Sign in to follow this  
Followers 0
lasaucisse

slider bk color on a tab control (solved)

11 posts in this topic

#1 ·  Posted (edited)

hi,

3 tabs on my GUI and 7 sliders on each one.

problem : tabs background color is almost white, and background color is the default grey of GUIs

- I searched on forum, and tried to use the _GUICtrlTab_SetBkColor() function, but AutoIt said "undefined function", while all required #include are ok.

- I tried the GUICtrlSetBkColor() function on sliders, to set the same color than tabs.

Well, it works... but the color is "fixed" by the program, so I guess if the Windows Theme change, the default tabs color will be different... but not the sliders.

so, questions :

- where can I find this _GUICtrlTab_SetBkColor() function ???

- or is there a way to set a transparent color on sliders ?

whatever the background colors, I'd like the same both on tabs and sliders !!

thanks :)

Edited by lasaucisse

[size="1"]mostly useless softwares (sorry for old VB softs ^^) & others things[/size]

Share this post


Link to post
Share on other sites



lasaucisse,

Here is how you can colour tabs and sliders - credit to Valik as it is based on his code: ;)

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>

; Tab colours
Global $aTabColours[4] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0]

; Create GUI
Global $hGUI = GUICreate ("Test", 400,300)
GUISetBkColor (0)

; Create label to cover tab "tab"
Global $hColourTab = GUICtrlCreateLabel("", 0, 0, 1, 1, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN))

; Create tab
Global $hTab = GUICtrlCreateTab(5, 5,390, 290)
Global $hTab_Handle = GUICtrlGetHandle($hTab)

; Create tab items and colour them
For $i = 0 To 3
    GUICtrlCreateTabItem ("Tab item - " & $i)
    _GUICtrlTab_SetBkColor($hGUI, $hTab, $aTabColours[$i])
    ; Add sliders
    GUICtrlCreateSlider(20, 100, 200, 20)
    GUICtrlSetBkColor(-1, $aTabColours[$i])
Next
GUICtrlCreateTabItem ("")

_GUICtrlTab_SetCurSel($hTab_Handle,0)
_GUICtrlTab_SetCurFocus($hTab_Handle,0)
TabEvent()

GUISetState ()

While 1
    Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            TabEvent()
    EndSwitch
WEnd

Func TabEvent()

    ; Set values
    Local $iTab_X = 5, $iTab_Y = 5, $iTab_Margin = 1
    ; Get index of current tab
    Local $iTab_Index = GUICtrlRead($hTab)
    ; Get coordinates of TabItem
    Local $aTab_Coord = _GUICtrlTab_GetItemRect($hTab_Handle, $iTab_Index)
    ; Get text of TabItem
    Local $sTab_Text = _GUICtrlTab_GetItemText($hTab_Handle, $iTab_Index)
    ; Place label
    GUICtrlSetPos($hColourTab, $iTab_X + $aTab_Coord[0] + $iTab_Margin, $iTab_Y + $aTab_Coord[1] + $iTab_Margin + 1, $aTab_Coord[2] - $aTab_Coord[0] - ($iTab_Margin * 2), $aTab_Coord[3] - $aTab_Coord[1] - ($iTab_Margin * 2) + 5)
    ; Set text
    GUICtrlSetData($hColourTab, $sTab_Text)
    ; Set colour
    GUICtrlsetBkColor ($hColourTab,$aTabColours[$iTab_Index] )
    ; Set focus
    _GUICtrlTab_SetCurFocus($hTab_Handle,$iTab_Index)

EndFunc

Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor)

    ; Get tab position
    Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32)
    ; Get size of user area
    Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1)
    ; Create label
    GUICtrlCreateLabel("", $aTabPos[0] + 2, $aTabPos[1] + $aTab_Rect[3] + 4, $aTabPos[2] - 6, $aTabPos[3] - $aTab_Rect[3] - 7)
    ; Colour label
    GUICtrlSetBkColor(-1, $sBkColor)
    ; Disable label
    GUICtrlSetState(-1, $GUI_DISABLE)

EndFunc   ;==>_GUICtrlTab_SetBkColor

If you want to get rid of the dotted lines around the sliders when you move them, take a look at the NoFocusLines UDF in my sig. :)

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

I'm going to try that ! thanks !!


[size="1"]mostly useless softwares (sorry for old VB softs ^^) & others things[/size]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

well, it works !

but with this way I need to add your code inside the "create section code" generated by Koda, and I'll have to do it after each modification into Koda ! it's not really usefull.

and I found another problem : there's no way (for moment) to disable a tab-item ! I could checked the selected tab, and return a message box on click like "this tab is actually disabled", with automatic focus to a good one. But it's not usefull, one again !

in fact, My GUI allows to set 1 ou 3 objects, and each tab-item get parameters for one.

if user choose "only 1 object mode", the 2nd and 3rd tabs need to be disabled.

so the 3 tab-items are exactly identicals : same buttons, same sliders, same inputs...

...

Initially, I choosed a tab system to access directly to each value : 1 tab-item = 1 object = 1 set of controls

but finally, I think I'm going to delete tabs, leave only the first set of controls, and adding 3 radio buttons to activate the 1st, 2nd or 3rd object.

so I'll need to store each control value for current object, and to update them if user change the current object to another one (actually, about 40 parameters....) :)

But it looks like "no tab" = "easiest" for what I want to do.

thank you anyway !!!

Edited by lasaucisse

[size="1"]mostly useless softwares (sorry for old VB softs ^^) & others things[/size]

Share this post


Link to post
Share on other sites

lasaucisse,

well, it works !

Have you ever come across the English expression: "damned with faint praise". If that is your considered response you are unlikely to get much help the next time you ask! ;)

My GUI allows to set 1 ou 3 objects, and each tab-item get parameters for one. if user choose "only 1 object mode", the 2nd and 3rd tabs need to be disabled.

Why create 3 tabs when the user just requires one? Surely a simple loop would produce as many tabs as were required? :)

That way there is no need to disable anything - as the unwanted tabs have never been created. :idiot:

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

Have you ever come across the English expression: "damned with faint praise". If that is your considered response you are unlikely to get much help the next time you ask! :idiot:

sorry, I don't know this expression (I'm french, my poor english is really basic...) but from what I understand from your sentence, I have the impression that you think I am not satisfied with your solution. :)

but I am ! I really thanks for your solution, I learned something !!! And I think I'll use it a next time... but in another context !

for this one, I realized that I didn't choose the good way with tabs, really.

At start, when I want to code a new program, I've got just a simple idea that I wanna do. Then, as and when I code, I discover new constraints or opportunities.

And about tabs, I really need to disable some "objects" : if user choose the "1 mode", I do not want him to have the option to click on enabled tabs to access others controls. I'm trying to code my application so that they're simplest possible fot user. And, as user, if I see an enabled tab on a GUI, I'll try to click on, and I won't like a message box that say "no way ! ".

This constraint is really more important than background colors : if I can't disable them, no tabs ! and then, nor background color problem... that's all.

So, I agree with you, I don't need 3 tabs : only one set of controls may suffice for my application, and I know how to disabled radio button :idiot:

The next time I'll ask, I hope you'll help me if you can ! ;)


[size="1"]mostly useless softwares (sorry for old VB softs ^^) & others things[/size]

Share this post


Link to post
Share on other sites

lasaucisse,

The next time I'll ask, I hope you'll help me if you can !

Bien sur - l'emoticon était la pour te dire que je ne faisais que rigoler! :)

Translation (short version): Yes

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

ah ok :)

I was not sure, because it's possible that in english I don't say exactly that I want, and I could be "rude" in my messages without realizing.

bye !


[size="1"]mostly useless softwares (sorry for old VB softs ^^) & others things[/size]

Share this post


Link to post
Share on other sites

Seems to have a little problem when using $WS_EX_CLIENTEDGE with listviews....

Just un-comment the GUICtrlCreateListView line in the for loop to see what I mean. Using $WS_EX_CLIENTEDGE seems to hide the listview until it is clicked on. Not sure if this is a bug or a feature :huh2:

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
#include <StaticConstants.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>

; Tab colours
Global $aTabColours[4] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0]

; Create GUI
Global $hGUI = GUICreate ("Test", 400,300)
GUISetBkColor (0)

; Create label to cover Tab "tab"
Global $hColourTab = GUICtrlCreateLabel("", 0, 0, 1, 1, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN))

; Create tab
Global $hTab = GUICtrlCreateTab(5, 5,390, 290)
Global $hTab_Handle = GUICtrlGetHandle($hTab)

; Create Tab items and colour them
For $i = 0 To 3
    GUICtrlCreateTabItem ("Tab item - " & $i)
    _GUICtrlTab_SetBkColor($hGUI, $hTab, $aTabColours[$i])
    ; add listview
    GUICtrlCreateListView("Col1¦Col2", 20, 50, 200, 200, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_NOSORTHEADER)) ; this works fine
    ;GUICtrlCreateListView("Col1¦Col2", 20, 50, 200, 200, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_NOSORTHEADER), $WS_EX_CLIENTEDGE) ; this doesn't
    GUICtrlCreateListViewItem("item2¦item2", -1)
    GUICtrlSetBkColor(-1, $aTabColours[$i])
Next
GUICtrlCreateTabItem ("")

_GUICtrlTab_SetCurSel($hTab_Handle,0)
_GUICtrlTab_SetCurFocus($hTab_Handle,0)
TabEvent()

GUISetState ()

While 1
    Switch GUIGetMsg ()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            TabEvent()
    EndSwitch
WEnd

Func TabEvent()

    ; Set values
    Local $iTab_X = 5, $iTab_Y = 5, $iTab_Margin = 1
    ; Get index of current tab
    Local $iTab_Index = GUICtrlRead($hTab)
    ; Get coordinates of TabItem
    Local $aTab_Coord = _GUICtrlTab_GetItemRect($hTab_Handle, $iTab_Index)
    ; Get text of TabItem
    Local $sTab_Text = _GUICtrlTab_GetItemText($hTab_Handle, $iTab_Index)
    ; Place label
    GUICtrlSetPos($hColourTab, $iTab_X + $aTab_Coord[0] + $iTab_Margin, $iTab_Y + $aTab_Coord[1] + $iTab_Margin + 1, $aTab_Coord[2] - $aTab_Coord[0] - ($iTab_Margin * 2), $aTab_Coord[3] - $aTab_Coord[1] - ($iTab_Margin * 2) + 5)
    ; Set text
    GUICtrlSetData($hColourTab, $sTab_Text)
    ; Set colour
    GUICtrlsetBkColor ($hColourTab,$aTabColours[$iTab_Index] )
    ; Set focus
    _GUICtrlTab_SetCurFocus($hTab_Handle,$iTab_Index)

EndFunc

Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor)

    ; Get Tab position
    Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32)
    ; Get size of user area
    Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1)
    ; Create label
    GUICtrlCreateLabel("", $aTabPos[0] + 2, $aTabPos[1] + $aTab_Rect[3] + 4, $aTabPos[2] - 6, $aTabPos[3] - $aTab_Rect[3] - 7)
    ; colour label
    GUICtrlSetBkColor(-1, $sBkColor)
    ; Disable label
    GUICtrlSetState(-1, $GUI_DISABLE)

EndFunc   ;==>_GUICtrlTab_SetBkColor

Share this post


Link to post
Share on other sites

PartyPooper,

Experience has shown that it is best to use _GUICtrlListView_SetExtendedListViewStyle when setting extended styles for ListViews. Adding them in the creation code leads to strange results, as you have discovered - particularly when the extended styles are not $LVS_EX_* ones: :huh2:

This code works fine for me: ;)

$hListView = GUICtrlCreateListView("Col1¦Col2", 20, 50, 200, 200, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_NOSORTHEADER))
_GUICtrlListView_SetExtendedListViewStyle($hListView, $WS_EX_CLIENTEDGE)

Does it work for you too?

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

Yes, that works as it should, thanks.

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