Jump to content

creating tab also focus a new tab


Recommended Posts

I have this script:

#include <GUIConstants.au3>
#include <Array.au3>
Dim $Letter1[13]
Global $letter = ""
$Form1 = GUICreate("Form1", 372, 225, 214, 154)
$Tab1 = GUICtrlCreateTab(32, 5, 305, 185)
$Tabitem1 = GUICtrlCreateTabItem("General")
$Button1 = GUICtrlCreateButton("Button1", 50, 50)
$tabitem2 = GUICtrlCreateTabItem("Something")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("")
$dodaj = GUICtrlCreateButton("Add", 32, 190)
$oduzmi = GUICtrlCreateButton("Delete", 200, 190)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $dodaj
            $neki_broj = Random(3,12, 1)
            for $i = 1 to $neki_broj
                $Letter1[$i] = Chr(Random(Asc("a"), Asc("z"), 1))
                $letter = $letter & $Letter1[$i]
            Next
            $promenljiva = GUICtrlCreateTabItem($letter)
            $Button2 = GUICtrlCreateButton("Button2", 80, 80)
            GUICtrlCreateTabItem("")
            $letter = ""
        case $oduzmi
            $selektovani_tab = GUICtrlRead($Tab1, 1)
            if $selektovani_tab <> $Tabitem1 And $selektovani_tab <> $Tabitem2 Then
                GUICtrlDelete ($selektovani_tab)
                GUICtrlSetState($selektovani_tab-4, $GUI_SHOW)
                GUICtrlSetState($selektovani_tab-2, $GUI_SHOW)
            EndIf
    EndSwitch
WEnd

and each time I create a new tab, I get focus on it, which I don't want to happen. I can delete GUICtrlCreateTabItem("") line under case $dodaj, then I don't get focus, but in that case after clicking ADD button I loose everything that is under "general" tab (button1). Can I make new tab without focusing to it?

Edited by sandin
Link to comment
Share on other sites

define what you mean by "focus" on a new tab

"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

Link to comment
Share on other sites

also displaying the entire script may help some people?

"FREEDOM is not FREE""Its a good thing war is so terrible, or we grow too fond of it" -Robert E. Lee[quote]Firestrom: global $warming = False[/quote]My scripts:Desktop Cleaner---->Total Downloads:167;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;111111;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;;;;;;;;;;;1;;;;;;1;;;;;;;;;;;;;;11;;;;;;"a wise man once said why use your skills when we have technology"

Link to comment
Share on other sites

So, this may help:

Note, the addition of $active and how $active is used under your new tab button

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
#include <Array.au3>
Dim $Letter1[13]
Global $letter = ""
$Form1 = GUICreate("Form1", 372, 225, 214, 154)
$Tab1 = GUICtrlCreateTab(32, 5, 305, 185)
$Tabitem1 = GUICtrlCreateTabItem("General")
$Button1 = GUICtrlCreateButton("Button1", 50, 50)
$tabitem2 = GUICtrlCreateTabItem("Something")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("")
$dodaj = GUICtrlCreateButton("Add", 32, 190)
$oduzmi = GUICtrlCreateButton("Delete", 200, 190)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    $active = GUICtrlRead($tab1, 1)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $dodaj
            $neki_broj = Random(3,12, 1)
            for $i = 1 to $neki_broj
                $Letter1[$i] = Chr(Random(Asc("a"), Asc("z"), 1))
                $letter = $letter & $Letter1[$i]
            Next
            $promenljiva = GUICtrlCreateTabItem($letter)
            $Button2 = GUICtrlCreateButton("Button2", 80, 80)
            GUICtrlCreateTabItem("")
            GUICtrlSetState($active, $GUI_SHOW)
            $letter = ""
        case $oduzmi
            $selektovani_tab = GUICtrlRead($Tab1, 1)
            if $selektovani_tab <> $Tabitem1 And $selektovani_tab <> $Tabitem2 Then
                GUICtrlDelete ($selektovani_tab)
                GUICtrlSetState($selektovani_tab-4, $GUI_SHOW)
                GUICtrlSetState($selektovani_tab-2, $GUI_SHOW)
            EndIf
    EndSwitch
WEnd
Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

tnx for replies

define what you mean by "focus" on a new tab

focus = set to be active

also displaying the entire script may help some people?

the post above is my entire script

So, this may help:

Note, the addition of $active and how $active is used under your new tab button

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
#include <Array.au3>
Dim $Letter1[13]
Global $letter = ""
$Form1 = GUICreate("Form1", 372, 225, 214, 154)
$Tab1 = GUICtrlCreateTab(32, 5, 305, 185)
$Tabitem1 = GUICtrlCreateTabItem("General")
$Button1 = GUICtrlCreateButton("Button1", 50, 50)
$tabitem2 = GUICtrlCreateTabItem("Something")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("")
$dodaj = GUICtrlCreateButton("Add", 32, 190)
$oduzmi = GUICtrlCreateButton("Delete", 200, 190)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    $active = GUICtrlRead($tab1, 1)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $dodaj
            $neki_broj = Random(3,12, 1)
            for $i = 1 to $neki_broj
                $Letter1[$i] = Chr(Random(Asc("a"), Asc("z"), 1))
                $letter = $letter & $Letter1[$i]
            Next
            $promenljiva = GUICtrlCreateTabItem($letter)
            $Button2 = GUICtrlCreateButton("Button2", 80, 80)
            GUICtrlCreateTabItem("")
            GUICtrlSetState($active, $GUI_SHOW)
            $letter = ""
        case $oduzmi
            $selektovani_tab = GUICtrlRead($Tab1, 1)
            if $selektovani_tab <> $Tabitem1 And $selektovani_tab <> $Tabitem2 Then
                GUICtrlDelete ($selektovani_tab)
                GUICtrlSetState($selektovani_tab-4, $GUI_SHOW)
                GUICtrlSetState($selektovani_tab-2, $GUI_SHOW)
            EndIf
    EndSwitch
WEnd
tnx, that does the trick :) however, my script above is just a simplified version of a real script, real script has lots of objects including IE, so making all those objects, selecting new-made tab, and restoring to current tab made my script flashy and slow. Can this be avoided? (making all those objects and tab in the background, without focusing to it at all)
Link to comment
Share on other sites

tnx for replies

focus = set to be active

the post above is my entire script

tnx, that does the trick :) however, my script above is just a simplified version of a real script, real script has lots of objects including IE, so making all those objects, selecting new-made tab, and restoring to current tab made my script flashy and slow. Can this be avoided? (making all those objects and tab in the background, without focusing to it at all)

Hum, hum, hum.

Is it possible to hide it right after you create it, and then add the controls to it, and then show the first tab?

It probably will still flicker, so scratch that idea............

TBH, i'm at a loss. I have no idea how to help you with this. You want to add controls to a tab, right after it's created, and still have the focus on the first tab; the best method (from my experience, which is limited vs everyone else :() i've already given you flickers, ie it switches to the new tab, and then builds the controls, and then switches to the proper tab.....

Try this and let me know if it still flickers:

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
#include <Array.au3>
Dim $Letter1[13]
Global $letter = ""
$Form1 = GUICreate("Form1", 372, 225, 214, 154)
$Tab1 = GUICtrlCreateTab(32, 5, 305, 185)
$Tabitem1 = GUICtrlCreateTabItem("General")
$Button1 = GUICtrlCreateButton("Button1", 50, 50)
$tabitem2 = GUICtrlCreateTabItem("Something")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("")
$dodaj = GUICtrlCreateButton("Add", 32, 190)
$oduzmi = GUICtrlCreateButton("Delete", 200, 190)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    $active = GUICtrlRead($tab1, 1)
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $dodaj
            $neki_broj = Random(3,12, 1)
            for $i = 1 to $neki_broj
                $Letter1[$i] = Chr(Random(Asc("a"), Asc("z"), 1))
                $letter = $letter & $Letter1[$i]
            Next
            $promenljiva = GUICtrlCreateTabItem($letter)
            GUICtrlSetState(-1, $GUI_HIDE)
            $Button2 = GUICtrlCreateButton("Button2", 80, 80)
            GUICtrlSetState($active, $GUI_SHOW)
            GUICtrlCreateTabItem("")
            $letter = ""
        case $oduzmi
            $selektovani_tab = GUICtrlRead($Tab1, 1)
            if $selektovani_tab <> $Tabitem1 And $selektovani_tab <> $Tabitem2 Then
                GUICtrlDelete ($selektovani_tab)
                GUICtrlSetState($selektovani_tab-4, $GUI_SHOW)
                GUICtrlSetState($selektovani_tab-2, $GUI_SHOW)
            EndIf
    EndSwitch
WEnd
Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

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