Sign in to follow this  
Followers 0

GUICtrlCreateTabitem

33 posts in this topic

Posted

I would love to be able to change the color of a tab. The code would be something like the following:

$tab1 = GuiCtrlCreateTabItem("Groups")
GUISetBkColor(0x00E0FFFF, $tab1)

From what I'm currently finding, this can't be done. I'm looking to make a GUI, but the names of the tabs will be a varable, depending on how the user names them. Is there a way to do this that I do not know about?

Share this post


Link to post
Share on other sites



Posted (edited)

I like this idea too. Be nice to change the colour of the Tab text as well.

$tab1 = GuiCtrlCreateTabItem("Groups")
GUICtrlSetColor(-1, 0x0000ff)

EDIT: forgot to include an example of what I mean.. DUH!

Edited by PartyPooper

Share this post


Link to post
Share on other sites

Posted

per help

The "tabitem" control cannot be painted (too much code ...)

8)

Share this post


Link to post
Share on other sites

Posted

:P

Share this post


Link to post
Share on other sites

Posted

It's a pity graphics don't work on tabs properly or you could use that to colour a tab.

Share this post


Link to post
Share on other sites

Posted

The "tabitem" control cannot be painted (too much code ...)

the one thing that was missing !! :D

isn't this gonna be fixed?

Share this post


Link to post
Share on other sites

Posted

the one thing that was missing !! :D

isn't this gonna be fixed?

Nice 2+ year bump...

And it's not a bug, it's just (as stated in the helpfile), not allowed becaues it would(probably) require too much code.

I would say that it's possible to do using dllcalls though.. but that's .. yep. that's that. :E

Share this post


Link to post
Share on other sites

Posted

Nice 2+ year bump...

And it's not a bug, it's just (as stated in the helpfile), not allowed becaues it would(probably) require too much code.

I would say that it's possible to do using dllcalls though.. but that's .. yep. that's that. :E

that's what?

I know it's not a bug what I meant is when is the coloring will be possible?

just give me a Dll function that can do the coloring stuff !!

I really need that right now

Share this post


Link to post
Share on other sites

Posted

that's what?

I know it's not a bug what I meant is when is the coloring will be possible?

Probably never.

just give me a Dll function that can do the coloring stuff !!

You'll have to try and find that yourself. I don't recall seeing where any of the users were working on it and since it's not a planned feature then you can bet the devs have more important issues an their minds.

I really need that right now

And I'm really sorry to hear that, becuase unless you find a method (using a dll or ocx file) by yourself then you will not have it "right now". And like freefly pointed out you have dragged up an issue that was dead 2 years ago. If anything was going to change it would have been posted by now.

Share this post


Link to post
Share on other sites

Posted (edited)

Probably never.

You'll have to try and find that yourself. I don't recall seeing where any of the users were working on it and since it's not a planned feature then you can bet the devs have more important issues an their minds.

And I'm really sorry to hear that, becuase unless you find a method (using a dll or ocx file) by yourself then you will not have it "right now". And like freefly pointed out you have dragged up an issue that was dead 2 years ago. If anything was going to change it would have been posted by now.

I've become an annoying person I guess !!

[ FreeFry ] mentioned that it can be done using the Dll Funcs, I tried to look in msdn long time ago, but to tell u the truth I was lost there !!

anyway thanks for the help and sorry for the inconvenience. :D

EDIT: [ what I meant by right now was at the present sorry for the rong word !! ]

Edited by star2

Share this post


Link to post
Share on other sites

Posted

I said that it could probably be done with DllCalls()..

other than that.. i recall seeing a custom library(include file) that allowed for much customized gui's, that was posted on this forum somewhere.. cant remember the name of it

Share this post


Link to post
Share on other sites

Posted

I have made a solution for it, see below

Hopefully it is easy to understand

To color the entire tab use: _GUICtrlTab_GetDisplayRect to find the coordinates

	Global $ColorTab
	$TabItem[0] = GUICtrlCreateTab(0, 50, 870, 831)
	GUICtrlSetOnEvent($TabItem[0], "TabEvent")

Func TabEvent()	
	Local $l_tab, $l_tabX, $l_tabY, $l_margin, $l_coord, $l_text
	$l_tab = _GUICtrlTab_GetCurSel(GUICtrlGetHandle($TabItem[0]))
	$l_tabX = 0 ; X-position in Main GUI
	$l_tabY = 50 ; Y-position in Main GUI
	$l_margin = 2 ; Margin in TabItem htat should not be colored
	$l_coord = _GUICtrlTab_GetItemRect(GUICtrlGetHandle($TabItem[0]), $l_tab); Get coordinates of TabItem 
	$l_text = _GUICtrlTab_GetItemText(GUICtrlGetHandle($TabItem[0]), $l_tab); Get text of TabItem
	GUICtrlDelete ($ColorTab) ; Delete the Label
	$ColorTab = GUICtrlCreateLabel($l_text,$l_tabX + $l_coord[0] + $l_margin ,$l_tabY + $l_coord[1] + $l_margin,$l_coord[2] - $l_coord[0] - ($l_margin * 2),$l_coord[3] - $l_coord[1] - ($l_margin * 2),BitOr($SS_NOTIFY,$SS_CENTER)); Create the label
	GUICtrlsetBkColor (-1,0xFFFFC0 ); set the color of the label
EndFunc

Share this post


Link to post
Share on other sites

Posted

I have made a solution for it, see below

Hopefully it is easy to understand

To color the entire tab use: _GUICtrlTab_GetDisplayRect to find the coordinates

	Global $ColorTab
	$TabItem[0] = GUICtrlCreateTab(0, 50, 870, 831)
	GUICtrlSetOnEvent($TabItem[0], "TabEvent")

Func TabEvent()	
	Local $l_tab, $l_tabX, $l_tabY, $l_margin, $l_coord, $l_text
	$l_tab = _GUICtrlTab_GetCurSel(GUICtrlGetHandle($TabItem[0]))
	$l_tabX = 0; X-position in Main GUI
	$l_tabY = 50; Y-position in Main GUI
	$l_margin = 2; Margin in TabItem htat should not be colored
	$l_coord = _GUICtrlTab_GetItemRect(GUICtrlGetHandle($TabItem[0]), $l_tab); Get coordinates of TabItem 
	$l_text = _GUICtrlTab_GetItemText(GUICtrlGetHandle($TabItem[0]), $l_tab); Get text of TabItem
	GUICtrlDelete ($ColorTab); Delete the Label
	$ColorTab = GUICtrlCreateLabel($l_text,$l_tabX + $l_coord[0] + $l_margin ,$l_tabY + $l_coord[1] + $l_margin,$l_coord[2] - $l_coord[0] - ($l_margin * 2),$l_coord[3] - $l_coord[1] - ($l_margin * 2),BitOr($SS_NOTIFY,$SS_CENTER)); Create the label
	GUICtrlsetBkColor (-1,0xFFFFC0 ); set the color of the label
EndFunc

thank you for working it around with the label cheat !!

I'm searching some final solution for the tab item coloring for good.

Share this post


Link to post
Share on other sites

Posted

I have also searched for it, but haven't found a solution so I made this cheat.

But after all it works until a better solution is found.

Share this post


Link to post
Share on other sites

Posted

responding to Wooltown cheat:

can anyone tell me what am I doing wrong:

if I compile the script it will give me a var error also the label seems disappear if the tab control loses focus for the first time

example:

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
Global $ColorTab, $TabItem
Local $l_tab, $l_tabX, $l_tabY, $l_margin, $l_coord, $l_text,$ColorTab
$main = GUICreate ("Test", 400,300)
GUISetBkColor (0)
$TabItem = GUICtrlCreateTab(5, 5,390, 260)
GUICtrlCreateTabItem ("Tab item - 1")
GUICtrlCreateTabItem ("")
GUICtrlCreateTabItem ("Tab item - 2")
GUICtrlCreateTabItem ("")
GUICtrlCreateTabItem ("Tab item - 3")
GUICtrlCreateTabItem ("")
GUICtrlCreateTabItem ("Tab item - 4")
GUICtrlCreateTabItem ("")
$go = GUICtrlCreateButton ("test", 5, 270, 390,25)

$l_tabo = _GUICtrlTab_GetCurSel(GUICtrlGetHandle($TabItem))
IniWrite ("test.ini", "Selected", "Tab item selected", $l_tabo)
$l_tab = _GUICtrlTab_GetCurSel(GUICtrlGetHandle($TabItem))
$l_coord = _GUICtrlTab_GetItemRect(GUICtrlGetHandle($TabItem), $l_tab); Get coordinates of TabItem
$l_text = _GUICtrlTab_GetItemText(GUICtrlGetHandle($TabItem), $l_tab); Get text of TabItem
GUICtrlGetHandle($ColorTab)
$ColorTab = GUICtrlCreateLabel($l_text,$l_coord[0] +5 ,$l_coord[1] + 5,$l_coord[2] - $l_coord[0],$l_coord[3] - $l_coord[1] ,BitOr($SS_NOTIFY,$SS_CENTER)); Create the label
GUICtrlsetBkColor ($ColorTab,0xFFFFC0 ); set the color of the label

GUISetState ()
While 1
	$msg = GUIGetMsg ()
	If $msg = $gui_event_close Then ExitLoop
	TabEvent()
WEnd

Func TabEvent()
	$test = IniRead ("test.ini", "Selected", "Tab item selected" , 0)
    $l_tab = _GUICtrlTab_GetCurSel(GUICtrlGetHandle($TabItem))
    $l_coord = _GUICtrlTab_GetItemRect(GUICtrlGetHandle($TabItem), $l_tab); Get coordinates of TabItem
    $l_text = _GUICtrlTab_GetItemText(GUICtrlGetHandle($TabItem), $l_tab); Get text of TabItem
	If $test <> $l_tab  Then
		$ColorTab = GUICtrlCreateLabel($l_text,$l_coord[0] +5 ,$l_coord[1] + 5,$l_coord[2] - $l_coord[0],$l_coord[3] - $l_coord[1] ,BitOr($SS_NOTIFY,$SS_CENTER)); Create the label
		GUICtrlsetBkColor ($ColorTab,0xFFFFC0 ); set the color of the label
		IniWrite ("test.ini", "Selected", "Tab item selected", $l_tab)
		$test = $l_tab
	EndIf
	If $msg = $go Then
		MsgBox (-1, "", _GUICtrlTab_GetItemState ($main,0))
	EndIf

EndFunc

Share this post


Link to post
Share on other sites

Posted

I made it work better, but still the problem when the tabs oses focus in the beginning, I will check more, have a lot of stuff to do rigt how.

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
Global $ColorTab, $TabItem, $go, $msg

$main = GUICreate ("Test", 400,300)
GUISetBkColor (0)
$TabItem = GUICtrlCreateTab(5, 5,390, 260)
GUICtrlCreateTabItem ("Tab item - 1")
GUICtrlCreateTabItem ("")
GUICtrlCreateTabItem ("Tab item - 2")
GUICtrlCreateTabItem ("")
GUICtrlCreateTabItem ("Tab item - 3")
GUICtrlCreateTabItem ("")
GUICtrlCreateTabItem ("Tab item - 4")
GUICtrlCreateTabItem ("")
$go = GUICtrlCreateButton ("test", 5, 270, 390,25)

_GUICtrlTab_SetCurSel(GUICtrlGetHandle($TabItem),0)
_GUICtrlTab_SetCurFocus(GUICtrlGetHandle($TabItem),0)
TabEvent()

GUISetState ()
While 1
	$msg = GUIGetMsg ()
	If $msg = $gui_event_close Then ExitLoop
	if $msg = $TabItem Then TabEvent()
	if $msg = $go Then Tab1()
WEnd

Func TabEvent()
	Local $l_tab, $l_tabX, $l_tabY, $l_margin, $l_coord, $l_text
  ; $test = IniRead ("test.ini", "Selected", "Tab item selected" , 0)
   	$l_tabX = 5
	$l_tabY = 5
	$l_margin = 1
	$l_tab = _GUICtrlTab_GetCurSel(GUICtrlGetHandle($TabItem))
	$l_coord = _GUICtrlTab_GetItemRect(GUICtrlGetHandle($TabItem), $l_tab); Get coordinates of TabItem
	$l_text = _GUICtrlTab_GetItemText(GUICtrlGetHandle($TabItem), $l_tab); Get text of TabItem
   ;If $test <> $l_tab  Then
		GUICtrlDelete($ColorTab)
		$ColorTab = GUICtrlCreateLabel($l_text, $l_tabX + $l_coord[0] + $l_margin, $l_tabY + $l_coord[1] + $l_margin, $l_coord[2] - $l_coord[0] - ($l_margin * 2), $l_coord[3] - $l_coord[1] - ($l_margin * 2), BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN))
		GUICtrlsetBkColor ($ColorTab,0xFFFFC0 ); set the color of the label
	;   IniWrite ("test.ini", "Selected", "Tab item selected", $l_tab)
	 ;  $test = $l_tab
   ;EndIf
	_GUICtrlTab_SetCurFocus(GUICtrlGetHandle($TabItem),$l_tab)
EndFunc
Func Tab1()
	If $msg = $go Then
		MsgBox (0, "", _GUICtrlTab_GetItemState ($main,0))
	EndIf
EndFunc

Share this post


Link to post
Share on other sites

Posted

I was really sleeping when I wrote this script and I woke up 2 hours ago but now I'm in the office now, can't wait to check for solution for losing focus.

nice job Wooltown

Share this post


Link to post
Share on other sites

Posted

by the way the compiling problem still exists !!

Share this post


Link to post
Share on other sites

Posted

I get it to work running Windows 2000 and the AutoIT 3.2.10.0

Share this post


Link to post
Share on other sites

Posted

The problem it loses focus and the label disappears, can it be an AutoIT bug ?

Share this post


Link to post
Share on other sites

Posted (edited)

did you try to compile it? it'll give you VAR error when running the exe

Edited by star2

Share this post


Link to post
Share on other sites

Posted

Compiled, works just fine !

Share this post


Link to post
Share on other sites

Posted

upload the error message and compiled script, and I will check !

Share this post


Link to post
Share on other sites

Posted

this is when you run the script file, and when running the exe file

post-22702-1201600541_thumb.jpg

post-22702-1201600564_thumb.jpg

Share this post


Link to post
Share on other sites

Posted

My script, in au3 and exe version, in attached zip-file

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.