Sign in to follow this  
Followers 0
SadBunny

How To Create Graphics On Tabs?

7 posts in this topic

How To Create Graphics On Tabs?

I wrote the following test code

GUICreate("My Main",400,400,100,100)

$tabs=GUICtrlCreateTab (2,2,396,396)

$tab1=GUICtrlCreateTabItem ("test tab 1")
$a=GuiCtrlCreateGraphic(100, 100, 100,100)
GUICtrlSetBkColor(-1,0x888888)
GUICtrlSetColor(-1,0x888888)

GUICtrlCreateTabItem ("")

GUISetState()

MsgBox(0,"test","Click OK to finish.")
Exit

I would like this code to make a GUI with in it a tab control, with on that tab a gray box. But this code does not show a gray box, only the tab. I can only get the gray box BEHIND the tab control on the main GUI (and then it sort of shines through the tab, but also through any other tab I would add). This can ofcourse be done by calling the CreateGraphic and Set(Bk)Color before the CreateTab call.

But... How to make a gray box (or any other CreateGraphic thingy) on one tab, so that the graph is only shown on that one tab and not on other tabs? I can't seem to get it done, and I can't find any info on it in the help or here in the forum. (I find it hard, btw, to define search terms for this question...)

Thanks in advance!


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites



Due to the implementation the graphics are always drawn in the background. The only think you can do is to have a tiny tab control displaying just the tabitems so the graphics controls associated with a specific tabitem will be dispayed.

Share this post


Link to post
Share on other sites

Many thanks for the very quick reply to my first post ever on this forum.

Too bad that it can't be done, actually I did not expect that because so many things I did not expect are already possible in this language!

But now I know... And I know that I should have posted my question here earlier, since I now have spent at least two hours in vain by testing, trying, thinking, searching for clues etc.. But: such is the life of the amateur coder :P

Thanks again!

Regards,

Sad Bunny


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Surely it's possible :P

Just use child windows...

Here is a small sample:

#include <GUIConstants.au3>

Global Const $WS_EX_CONTROLPARENT   = 0x00010000

; Main GUI
$hMainGUI   = GUICreate("Tab Sample", 400, 300)
$BtnOK      = GUICtrlCreateButton("OK", 110, 270, 70, 20)
$BtnCancel  = GUICtrlCreateButton("Cancel", 220, 270, 70, 20)
GUISetState()

; Child GUI1
$hChild1    = GUICreate("", 370, 215, 15, 40, BitOr($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $hMainGUI)
;GUISetBkColor(0x257788); just for dimensing the child

$nGraphic1  = GuiCtrlCreateGraphic(100, 100, 100,100)
GUICtrlSetBkColor(-1, 0xEE8844)
GUICtrlSetColor(-1, 0)

GUISetState()

; Child GUI2
$hChild2    = GUICreate("", 370, 215, 15, 40, BitOr($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $hMainGUI)
;GUISetBkColor(0x887788); just for dimensing the child

$nGraphic2  = GuiCtrlCreateGraphic(100, 100, 100, 100)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFF0000, 0xFFFF00)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 10, 10, 50, 50)


GUISwitch($hMainGUI)
$nTab       = GUICtrlCreateTab(10, 10, 380, 250)
$nTabitem1  = GUICtrlCreateTabItem("Tab1")
$nTabitem2  = GUICtrlCreateTabItem("Tab2")
GUICtrlCreateTabItem("")
GUICtrlSetState($nTabitem1, $GUI_SHOW)

While 1
    $Msg = GUIGetMsg()
    
    Switch $Msg
        Case $GUI_EVENT_CLOSE, $BtnCancel
            ExitLoop
            
        Case $nTab
            Switch GUICtrlRead($nTab) 
                Case 0
                    GUISetState(@SW_HIDE, $hChild2)
                    GUISetState(@SW_SHOW, $hChild1)
            
                Case 1
                    GUISetState(@SW_HIDE, $hChild1)
                    GUISetState(@SW_SHOW, $hChild2)
            EndSwitch
    EndSwitch
WEnd

Exit

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Surely it's possible :P

Just use child windows...

Here is a small sample:

VERY nice example Holger, thanks

I will copy it to my personal scripts & scraps also as very good example for child windows.

Edited by Zedna

Share this post


Link to post
Share on other sites

Ok people, thanks for the help. I now have some example code. Though it is a somewhat dirty trick (reading what tab is activated and switching enabled states of two previously created GUIs - the interpreter does have to do work so it's not "really" connected to the tab...) it does what I want it to do.

I am not very sure what the BitOr function does though. The help says it can be used to combine stuff with the default options but since I feel uncomfortable by using functions that I do not understand (then I cannot predict what will happen which makes troubleshooting hard) I cut that part out and saved it for later study (I only started using autoIT about 10 days ago - enough to practise as it is :P). With only $WS_Child as style and no extended styles, the result is exactly the same...

Ok so now I'll toy around with this a bit and then I will be able to create a framework of lines, automatically depending on the amount of functions I add to the code. That's what it was intended for in the first place.

Thanks again.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Blast from the past :whistle: After a bit of testing I used JPM's suggestion which works perfectly fine for me. I almost forgot I ever dealt with this problem. :)


Roses are FF0000, violets are 0000FF... All my base are belong to you.

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