Hallo Zusammen,
ich such jetzt schon seit 2 Stunden nach einer Lösung, aber irgendwie hab ich bisher nicht den richtigen Befehl oder Option zum Refreshen gefunden.
In einem normalen Fenster ohne Tabs funktioniert das GUICtrlCreateGraphic und GUICtrlDelete per Knopfdruck. Sobald ich aber mit Tabs arbeite, klappt es nicht mehr. Oft reicht ein Umschalten der Tabs oder ein Minimieren mit anschließendem Maximieren. Ich hätte das aber gerne ohne diesen Workaround
Was ist die entscheidende Option oder Befehl?
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]TestOhneTab()
TestMitTabs()
; Gui ohne Tabs
Func TestOhneTab()
Local Const $MyGuiWidth = 400
Local Const $MyGuiHeight = 300
Local Const $SignSize = 15
Local $MySign1 = -1
Local $MySign2 = -1
Local $msg
Local $MyGui = GUICreate("Test ohne Tab", $MyGuiWidth, $MyGuiHeight)
[/autoit] [autoit][/autoit] [autoit]$MySign1 = GUICtrlCreateGraphic(50, 50, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FF00, 0x00FF00)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
$MySign2 = GUICtrlCreateGraphic(50, 100, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FFFF, 0x00FFFF)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
Local $MyTestButtonAdd = GUICtrlCreateButton("Add", $MyGuiWidth - 100, 50, 50, 20)
[/autoit] [autoit][/autoit] [autoit]Local $MyTestButtonDelete = GUICtrlCreateButton("Delete", $MyGuiWidth - 100, 100, 50, 20)
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW, $MyGui)
[/autoit] [autoit][/autoit] [autoit]; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
[/autoit] [autoit][/autoit] [autoit]Case $GUI_EVENT_CLOSE
ExitLoop
Case $MyTestButtonDelete
If $MySign1 == -1 Then
MsgBox(16 + 262144, "Fehler", "Signs sind bereits gelöscht!")
Else
GUICtrlDelete($MySign1)
$MySign1 = -1
GUICtrlDelete($MySign2)
$MySign2 = -1
EndIf
Case $MyTestButtonAdd
If $MySign1 == -1 Then
$MySign1 = GUICtrlCreateGraphic(50, 50, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FF00, 0x00FF00)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
$MySign2 = GUICtrlCreateGraphic(50, 100, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FFFF, 0x00FFFF)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
Else
MsgBox(16 + 262144, "Fehler", "Signs sind bereits da!")
EndIf
EndSwitch
WEnd
GUIDelete($MyGui)
[/autoit] [autoit][/autoit] [autoit]EndFunc ;==>TestOhneTab
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]; Gui mit Tabs
Func TestMitTabs()
Local Const $MyGuiWidth = 400
Local Const $MyGuiHeight = 300
Local Const $SignSize = 15
Local $MySign1 = -1
Local $MySign2 = -1
Local $msg
Local $MyGui = GUICreate("Test mit Tabs", $MyGuiWidth, $MyGuiHeight)
[/autoit] [autoit][/autoit] [autoit]Local $MyTabs = GUICtrlCreateTab(0, 0, $MyGuiWidth - 10, $MyGuiHeight - 10)
[/autoit] [autoit][/autoit] [autoit]Local $MyTabOne = GUICtrlCreateTabItem("Tab 1")
[/autoit] [autoit][/autoit] [autoit]$MySign1 = GUICtrlCreateGraphic(50, 50, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FF00, 0x00FF00)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
GUICtrlSetState(-1, $GUI_ONTOP) ; <--
$MySign2 = GUICtrlCreateGraphic(50, 100, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FFFF, 0x00FFFF)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
GUICtrlSetState(-1, $GUI_ONTOP) ; <--
Local $MyTestButtonAdd = GUICtrlCreateButton("Add", $MyGuiWidth - 100, 50, 50, 20)
[/autoit] [autoit][/autoit] [autoit]Local $MyTestButtonDelete = GUICtrlCreateButton("Delete", $MyGuiWidth - 100, 100, 50, 20)
[/autoit] [autoit][/autoit] [autoit]Local $MyTabTwo = GUICtrlCreateTabItem("Tab 2")
[/autoit] [autoit][/autoit] [autoit]Local $MyTestButtonClose = GUICtrlCreateButton("Close", $MyGuiWidth - 150, $MyGuiHeight - 150, 50, 20)
[/autoit] [autoit][/autoit] [autoit]GUICtrlCreateTabItem("") ; close tabitem creation
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW, $MyGui)
[/autoit] [autoit][/autoit] [autoit]; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
[/autoit] [autoit][/autoit] [autoit]Case $GUI_EVENT_CLOSE, $MyTestButtonClose
ExitLoop
Case $MyTestButtonDelete
If $MySign1 == -1 Then
MsgBox(16 + 262144, "Fehler", "Signs sind bereits gelöscht!")
Else
; GUISwitch($MyGui, $MyTabs)
GUISwitch($MyGui, $MyTabOne)
GUICtrlDelete($MySign1)
$MySign1 = -1
GUICtrlDelete($MySign2)
$MySign2 = -1
EndIf
Case $MyTestButtonAdd
If $MySign1 == -1 Then
; GUISwitch($MyGui, $MyTabs)
GUISwitch($MyGui, $MyTabOne)
$MySign1 = GUICtrlCreateGraphic(50, 50, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FF00, 0x00FF00)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
GUICtrlSetState(-1, $GUI_ONTOP) ; <--
$MySign2 = GUICtrlCreateGraphic(50, 100, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00FFFF, 0x00FFFF)
GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 0, 0, $SignSize, $SignSize)
GUICtrlSetGraphic(-1, $GUI_GR_REFRESH)
GUICtrlSetState(-1, $GUI_ONTOP) ; <--
; GUISetState(@SW_SHOW, $MyGui)
Else
MsgBox(16 + 262144, "Fehler", "Signs sind bereits da!")
EndIf
EndSwitch
WEnd
GUIDelete($MyGui)
[/autoit] [autoit][/autoit] [autoit]EndFunc ;==>TestMitTabs
[/autoit]Besten Dank und happy computing!
R@iner