IE-Tabs im Gui

  • Aloha!
    Also ich will in meiner Gui Tabs erstellen, aber bevor jemand auf die falsche Idee kommt: GuiCtrlCreateTab mein ich nich :D

    Ich will nämlich am oberen Rand der Gui Tabs, wie im IE oder Firefox etc erstellen (Also drückt mal Strg+T, dann wisst ihr was ich meine)
    Doch wie mir im Portals-Chat gesagt wurde scheint das garnicht mal so einfach zu sein wie ich dachte.. Zur not würde ich auch statt tabs, buttons in den oberen rand setzen die per click den Inhalt der Gui ändern, aber einfachere und vorallem elegantere lösungen wären mir lieber...

    Bin auf eure (evtlen) Lösungen gespannt ^^

    MFG Apfeltasche

    Einmal editiert, zuletzt von Apfeltasche (15. Februar 2009 um 17:57)

  • Hallo Apfeltasche,

    ich hätte da einen Ansatz für Dich.
    Hab das jetzt nicht mit Tab's probiert, geht aber bestimmt auch.
    Ist natürlich nur ein Ansatz und weit entfernt davon perfekt zu sein.
    Ich denke aber das kann man ausbauen...

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <GuiTab.au3>
    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("MustDeclareVars", 1)
    Opt("GUIOnEventMode", 1)
    Const $main_gui_width = 860
    Const $main_gui_height = 710
    Const $child_gui_width = 860
    Const $child_gui_height = 660
    Const $btn_bkcol = 0xd4d0c8
    Const $btn_col = 0x000000
    Const $btn_bkcol_a = 0x0a246a
    Const $btn_col_a = 0xffffff
    Global $dll = DllOpen("user32.dll")
    Global $btn_child[6]
    Global $btn_shown = 1
    Global $strg_t = 0
    Global $title = "Demo für Child-Fenster"
    Global $dummy = GUICtrlCreateLabel("", 0, 0, 1, 1)
    Global $main_gui = GUICreate($title, $main_gui_width, $main_gui_height, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    Global $child1_gui, $child2_gui, $child3_gui, $child4_gui, $child5_gui, $child_akt, $child_old
    $btn_child[1] = GUICtrlCreateButton("Button 1", 10, 0, 160, 30)
    GUICtrlSetFont(-1, 10, 300)
    GUICtrlSetOnEvent(-1, "child_show")
    $btn_child[2] = GUICtrlCreateButton("Button 2", 180, 0, 160, 30)
    GUICtrlSetFont(-1, 10, 300)
    GUICtrlSetOnEvent(-1, "child_show")
    GUICtrlSetState(-1, $GUI_HIDE)
    $btn_child[3] = GUICtrlCreateButton("Button 3", 350, 0, 160, 30)
    GUICtrlSetFont(-1, 10, 300)
    GUICtrlSetOnEvent(-1, "child_show")
    GUICtrlSetState(-1, $GUI_HIDE)
    $btn_child[4] = GUICtrlCreateButton("Button 4", 520, 0, 160, 30)
    GUICtrlSetFont(-1, 10, 300)
    GUICtrlSetOnEvent(-1, "child_show")
    GUICtrlSetState(-1, $GUI_HIDE)
    $btn_child[5] = GUICtrlCreateButton("Button 5", 690, 0, 160, 30)
    GUICtrlSetFont(-1, 10, 300)
    GUICtrlSetOnEvent(-1, "child_show")
    GUICtrlSetState(-1, $GUI_HIDE)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

    [/autoit] [autoit][/autoit] [autoit]

    child1_gui()
    child2_gui()
    child3_gui()
    child4_gui()
    child5_gui()

    [/autoit] [autoit][/autoit] [autoit]

    $child_akt = $child1_gui ; um letzten aktiven Button wieder neutral zu färben
    GUICtrlSetBkColor($btn_child[1], $btn_bkcol_a)
    GUICtrlSetColor($btn_child[1], $btn_col_a)
    GUICtrlSetState($dummy, $GUI_FOCUS)
    GUISetState(@SW_SHOW, $main_gui)
    GUISetState(@SW_SHOW, $child1_gui)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    If _IsPressed("11", $dll) And _IsPressed("54", $dll) Then
    show_btn()
    EndIf
    Sleep(1)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func show_btn()
    If $btn_shown = 5 Then Return
    GUICtrlSetState($btn_child[$btn_shown + 1], $GUI_Show)
    $btn_shown += 1
    $strg_t = 0
    Sleep(500)
    EndFunc ;==>show_btn

    [/autoit] [autoit][/autoit] [autoit]

    Func child_show()
    $child_old = $child_akt
    Switch @GUI_CtrlId
    Case $btn_child[1]
    If $child_akt <> $child1_gui Then
    GUISetState(@SW_HIDE, $child_akt)
    GUISetState(@SW_SHOW, $child1_gui)
    $child_akt = $child1_gui
    GUICtrlSetBkColor($btn_child[1], $btn_bkcol_a)
    GUICtrlSetColor($btn_child[1], $btn_col_a)
    GUICtrlSetState($dummy, $GUI_FOCUS)
    EndIf
    Case $btn_child[2]
    If $child_akt <> $child2_gui Then
    GUISetState(@SW_HIDE, $child_akt)
    GUISetState(@SW_SHOW, $child2_gui)
    $child_akt = $child2_gui
    GUICtrlSetBkColor($btn_child[2], $btn_bkcol_a)
    GUICtrlSetColor($btn_child[2], $btn_col_a)
    GUICtrlSetState($dummy, $GUI_FOCUS)
    EndIf
    Case $btn_child[3]
    If $child_akt <> $child3_gui Then
    GUISetState(@SW_HIDE, $child_akt)
    GUISetState(@SW_SHOW, $child3_gui)
    $child_akt = $child3_gui
    GUICtrlSetBkColor($btn_child[3], $btn_bkcol_a)
    GUICtrlSetColor($btn_child[3], $btn_col_a)
    GUICtrlSetState($dummy, $GUI_FOCUS)
    EndIf
    Case $btn_child[4]
    If $child_akt <> $child4_gui Then
    GUISetState(@SW_HIDE, $child_akt)
    GUISetState(@SW_SHOW, $child4_gui)
    $child_akt = $child4_gui
    GUICtrlSetBkColor($btn_child[4], $btn_bkcol_a)
    GUICtrlSetColor($btn_child[4], $btn_col_a)
    GUICtrlSetState($dummy, $GUI_FOCUS)
    EndIf
    Case $btn_child[5]
    If $child_akt <> $child5_gui Then
    GUISetState(@SW_HIDE, $child_akt)
    GUISetState(@SW_SHOW, $child5_gui)
    $child_akt = $child5_gui
    GUICtrlSetBkColor($btn_child[5], $btn_bkcol_a)
    GUICtrlSetColor($btn_child[5], $btn_col_a)
    GUICtrlSetState($dummy, $GUI_FOCUS)
    EndIf
    EndSwitch
    If $child_old <> $child_akt Then
    Switch $child_old
    Case $child1_gui
    GUICtrlSetBkColor($btn_child[1], $btn_bkcol)
    GUICtrlSetColor($btn_child[1], $btn_col)
    Case $child2_gui
    GUICtrlSetBkColor($btn_child[2], $btn_bkcol)
    GUICtrlSetColor($btn_child[2], $btn_col)
    Case $child3_gui
    GUICtrlSetBkColor($btn_child[3], $btn_bkcol)
    GUICtrlSetColor($btn_child[3], $btn_col)
    Case $child4_gui
    GUICtrlSetBkColor($btn_child[4], $btn_bkcol)
    GUICtrlSetColor($btn_child[4], $btn_col)
    Case $child5_gui
    GUICtrlSetBkColor($btn_child[5], $btn_bkcol)
    GUICtrlSetColor($btn_child[5], $btn_col)
    EndSwitch
    EndIf

    EndFunc ;==>child_show
    Func child1_gui()
    $child1_gui = GUICreate("", $child_gui_width, $child_gui_height, 0, 10, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $main_gui)
    GUICtrlCreateLabel("Dies ist Seite 1", 50, 200, 200, 30)
    GUICtrlSetFont(-1, 12, 600)
    GUISetState(@SW_HIDE, $child1_gui)
    EndFunc ;==>child1_gui
    Func child2_gui()
    $child2_gui = GUICreate("", $child_gui_width, $child_gui_height, 0, 10, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $main_gui)
    GUICtrlCreateLabel("Dies ist Seite 2", 50, 200, 200, 30)
    GUICtrlSetFont(-1, 12, 600)
    GUISetState(@SW_HIDE, $child2_gui)
    EndFunc ;==>child2_gui
    Func child3_gui()
    $child3_gui = GUICreate("", $child_gui_width, $child_gui_height, 0, 10, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $main_gui)
    GUICtrlCreateLabel("Dies ist Seite 3", 50, 200, 200, 30)
    GUICtrlSetFont(-1, 12, 600)
    GUISetState(@SW_HIDE, $child3_gui)
    EndFunc ;==>child3_gui
    Func child4_gui()
    $child4_gui = GUICreate("", $child_gui_width, $child_gui_height, 0, 10, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $main_gui)
    GUICtrlCreateLabel("Dies ist Seite 4", 50, 200, 200, 30)
    GUICtrlSetFont(-1, 12, 600)
    GUISetState(@SW_HIDE, $child4_gui)
    EndFunc ;==>child4_gui
    Func child5_gui()
    $child5_gui = GUICreate("", $child_gui_width, $child_gui_height, 0, 10, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $main_gui)
    GUICtrlCreateLabel("Dies ist Seite 5", 50, 200, 200, 30)
    GUICtrlSetFont(-1, 12, 600)
    GUISetState(@SW_HIDE, $child5_gui)
    EndFunc ;==>child5_gui

    [/autoit] [autoit][/autoit] [autoit]

    Func CLOSEClicked()
    Exit 0
    EndFunc ;==>CLOSEClicked

    [/autoit]

    MfG Schnuffel

    "Sarkasmus ist die niedrigste Form des Witzes, aber die höchste Form der Intelligenz."
    Val McDermid

    ein paar Infos ...

    Wer mehr als "nur" Hilfe benötigt, kann sich gern im Forum "Programmieranfragen" an uns wenden. Wir helfen in allen Fällen, die die Forenregeln zulassen.

    Für schnelle Hilfe benötigen wir ein ! lauffähiges ! Script, dass wir als Demonstration des Problems testen können. Wer von uns erwartet ein Teilscript erstmal lauffähig zu bekommen, der hat
    1. keine wirkliche Not
    2. keinen Respekt vor Menschen die ihm in ihrer Freizeit Ihre Hilfe anbieten
    3. oder ist einfach nur faul und meint wir coden das für ihn

    In solchen Fällen erlaube ich mir, die Anfrage einfach zu ignorieren. ;)

  • Ich hab mir jetzt nicht Schnuffels Code angeguckt,

    aber ich würde Strg+T als Hotkey definieren, und dann eine GUI-Anweisung, die Tabs erstellt, ganz easy ;)

  • Vielen Dank Schnuffel für deinen coolen ansatz =)
    Es geht zwar in die richtige Richtung, es ist aber nicht 100% das was ich will... ich habe auch nochmal ein wenig gegooglt und meine Gehirnzellen angeschmissen und bin auch auf eine evtle etwas simplere Lösung gestoßen:

    Spoiler anzeigen
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    $hGUI = GUICreate("Test", 300, 200)

    [/autoit] [autoit][/autoit] [autoit]

    $cTab = GUICtrlCreateTab(10, 10, 280, 180)

    [/autoit] [autoit][/autoit] [autoit]

    $hImage = _GUIImageList_Create(32, 32, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 13, True)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 14, True)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 15, True)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlTab_SetImageList($cTab, $hImage)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlTab_InsertItem($cTab, 0, "Item 1", 0)
    _GUICtrlTab_InsertItem($cTab, 1, "Item 2", 1)
    _GUICtrlTab_InsertItem($cTab, 2, "Item 3", 2)
    $lab1 =GuiCtrlCreateLabel("Label1", 30, 60)
    $but1 =GuiCtrlCreateButton("Button1", 30, 90)
    $rad1 =GuiCtrlCreateRadio("Radio1", 30, 120)
    $che1=GuiCtrlCreateCheckbox("Check1", 30, 150)
    $lab2 =GuiCtrlCreateLabel("Label2", 120, 60)
    GuiCtrlSetState($lab2, $GUI_HIDE)
    $but2 =GuiCtrlCreateButton("Button2", 120, 90)
    GuiCtrlSetState($but2, $GUI_HIDE)
    $rad2 =GuiCtrlCreateRadio("Radio2", 120, 120)
    GuiCtrlSetState($rad2, $GUI_HIDE)
    $che2=GuiCtrlCreateCheckbox("Check2", 120, 150)
    GuiCtrlSetState($che2, $GUI_HIDE)
    $lab3 =GuiCtrlCreateLabel("Label3", 210, 60)
    GuiCtrlSetState($lab3, $GUI_HIDE)
    $but3 =GuiCtrlCreateButton("Button3", 210, 90)
    GuiCtrlSetState($but3, $GUI_HIDE)
    $rad3 =GuiCtrlCreateRadio("Radio3", 210, 120)
    GuiCtrlSetState($rad3, $GUI_HIDE)
    $che3=GuiCtrlCreateCheckbox("Check3", 210, 150)
    GuiCtrlSetState($che3, $GUI_HIDE)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $changeflag =_GUICtrlTab_GetCurFocus($cTab)
    If $changeflag = 0 Then
    GuiCtrlSetState($lab1, $GUI_SHOW)
    GuiCtrlSetState($but1, $GUI_SHOW)
    GuiCtrlSetState($rad1, $GUI_SHOW)
    GuiCtrlSetState($che1, $GUI_SHOW)
    GuiCtrlSetState($lab2, $GUI_HIDE)
    GuiCtrlSetState($but2, $GUI_HIDE)
    GuiCtrlSetState($rad2, $GUI_HIDE)
    GuiCtrlSetState($che2, $GUI_HIDE)
    GuiCtrlSetState($lab3, $GUI_HIDE)
    GuiCtrlSetState($but3, $GUI_HIDE)
    GuiCtrlSetState($rad3, $GUI_HIDE)
    GuiCtrlSetState($che3, $GUI_HIDE)
    ElseIf $changeflag = 1 Then
    GuiCtrlSetState($lab2, $GUI_SHOW)
    GuiCtrlSetState($but2, $GUI_SHOW)
    GuiCtrlSetState($rad2, $GUI_SHOW)
    GuiCtrlSetState($che2, $GUI_SHOW)
    GuiCtrlSetState($lab1, $GUI_HIDE)
    GuiCtrlSetState($but1, $GUI_HIDE)
    GuiCtrlSetState($rad1, $GUI_HIDE)
    GuiCtrlSetState($che1, $GUI_HIDE)
    GuiCtrlSetState($lab3, $GUI_HIDE)
    GuiCtrlSetState($but3, $GUI_HIDE)
    GuiCtrlSetState($rad3, $GUI_HIDE)
    GuiCtrlSetState($che3, $GUI_HIDE)
    ElseIf $changeflag = 2 Then
    GuiCtrlSetState($lab3, $GUI_SHOW)
    GuiCtrlSetState($but3, $GUI_SHOW)
    GuiCtrlSetState($rad3, $GUI_SHOW)
    GuiCtrlSetState($che3, $GUI_SHOW)
    GuiCtrlSetState($lab1, $GUI_HIDE)
    GuiCtrlSetState($but1, $GUI_HIDE)
    GuiCtrlSetState($rad1, $GUI_HIDE)
    GuiCtrlSetState($che1, $GUI_HIDE)
    GuiCtrlSetState($lab2, $GUI_HIDE)
    GuiCtrlSetState($but2, $GUI_HIDE)
    GuiCtrlSetState($rad2, $GUI_HIDE)
    GuiCtrlSetState($che2, $GUI_HIDE)
    EndIf
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit]

    Das Problem ist, das alles noch extremst flackert und recht unvollständig ist, aber so ungefähr will ichs haben...

    Wenn es nicht mehr flackern würde, wäre das schon ein recht großer fortschritt für mich =P
    Andere Verbesserungen sind natürlich auch mehr als willkommen..

    MFG

    Einmal editiert, zuletzt von Apfeltasche (15. Februar 2009 um 15:58)

  • Hi,
    so in etwa?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiTab.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ; Create GUI
    $hGUI = GUICreate("Test", 300, 200)
    $hTab = GUICtrlCreateTab(2, 2, 396, 296)

    [/autoit] [autoit][/autoit] [autoit]

    ; Create images
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 13)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 14)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 15)
    _GUICtrlTab_SetImageList($hTab, $hImage)

    [/autoit] [autoit][/autoit] [autoit]

    $tab0 = GUICtrlCreateTabItem("Tab 0")
    $lab1 = GUICtrlCreateLabel("Label1", 30, 60)
    $but1 = GUICtrlCreateButton("Button1", 30, 90)
    $rad1 = GUICtrlCreateRadio("Radio1", 30, 120)
    $che1 = GUICtrlCreateCheckbox("Check1", 30, 150)
    $lab2 = GUICtrlCreateLabel("Label2", 120, 60)
    GUICtrlCreateTabItem("")

    [/autoit] [autoit][/autoit] [autoit]

    $tab1 = GUICtrlCreateTabItem("Tab 1")
    $but2 = GUICtrlCreateButton("Button2", 120, 90)
    $rad2 = GUICtrlCreateRadio("Radio2", 120, 120)
    $che2 = GUICtrlCreateCheckbox("Check2", 120, 150)
    GUICtrlCreateTabItem("")

    [/autoit] [autoit][/autoit] [autoit]

    $tab2 = GUICtrlCreateTabItem("Tab 2")
    $lab3 = GUICtrlCreateLabel("Label3", 210, 60)
    $but3 = GUICtrlCreateButton("Button3", 210, 90)
    $rad3 = GUICtrlCreateRadio("Radio3", 210, 120)
    $che3 = GUICtrlCreateCheckbox("Check3", 210, 150)
    GUICtrlCreateTabItem("")

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetState($tab0, $GUI_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlTab_SetItem($hTab, 0, -1, -1, 0)
    _GUICtrlTab_SetItem($hTab, 1, -1, -1, 1)
    _GUICtrlTab_SetItem($hTab, 2, -1, -1, 2)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    [/autoit]
  • Hallo Apfeltasche,

    das flackern liegt daran, daß die Gui SetState fortwährend ausführt, habe dein Script etwas verändert um dies abzustellen

    mfg

    die Lösung von anno2008 ist sauberer

    Einmal editiert, zuletzt von AutoBert (15. Februar 2009 um 17:42)

  • Vielen Dank an anno und autoberd =) klappt beides super und annos script ist noch dazu platzsparend...
    Mir ist zwar noch aufgefallen das manchmal die buttons in den tabs etwas langsam reagieren und man öfter 2-3 klicken muss damit sich der button meldet und man in der regel 2-3 aufs x klicken muss bis sich das script schließt, aber ich denke damit kann ich mehr als zufrieden leben.

    Ty, Apfeltasche