So, jetzt nochmal ein Fix, damit der Fehler garnicht erst vorkommen kann:
Func _TreeAdd()
$AddForm = GUICreate("Add", 200, 65, -1, -1, $GUI_SS_DEFAULT_GUI, -1, $MainForm)
GUISetFont(10, 400, 0, "Verdana")
$AddInput = GUICtrlCreateInput("", 10, 10, 180, 20)
$AddOk = GUICtrlCreateButton("Ok", 37.5, 10+25, 60, 25)
$AddCancel = GUICtrlCreateButton("Cancel", 102.5, 10+25, 60, 25)
GUISetState()
GUISetState(@SW_DISABLE, $MainForm)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $AddCancel
ExitLoop
Case $AddOk
$Read = GUICtrlRead($AddInput)
If $Read = "" Then
_Error("Please enter a form name!", $AddForm)
ElseIf StringIsAlNum($Read) = 0 Then
_Error("You can't use special characters!", $AddForm)
Else
If FileExists($FORMS & "\" & $Read) Then
_Error("This form already exists!", $AddForm)
Else
GUICtrlCreateTreeViewItem($Read, $TreeView)
$File = FileOpen($FORMS & "\" & $Read, 10)
; Lets write our file with one Object ;)
FileWrite ($File, "[Objects]" & @CRLF & "Main=WTYPE_BASE|0|0|300|400|0x2220000|4")
FileClose($File)
_AppletOpen($Read)
ExitLoop
EndIf
EndIf
EndSwitch
WEnd
GUISetState(@SW_ENABLE, $MainForm)
GUIDelete($AddForm)
EndFunc
Alles anzeigen
Es wird direkt ein Standardobjekt (WTYPE_BASE) erstellt.