Jump to content

Problem, GuiDelete (?)


Recommended Posts

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>

Global $GUI = GUICreate("Kulinarne przepisy", 293, 294, 302, 218)
Global $Przepisy = GUICtrlCreateList("xd", 0, 0, 153, 292)
$Skasuj = GUICtrlCreateButton("Skasuj", 160, 146, 129, 49)
$Dodaj = GUICtrlCreateButton("Dodaj", 160, 90, 129, 49)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Dodaj
            Dodaj()

        Case $Skasuj
        If Not GUICtrlRead($Przepisy) = "" Then

            $DoSkasownia = _GUICtrlListBox_FindInText($Przepisy, GUICtrlRead($Przepisy))
            _GUICtrlListBox_DeleteString($Przepisy, $DoSkasownia)
        EndIf

    EndSwitch
WEnd




Func Dodaj()
Local $GuiDodaj = GUICreate("Dodawanie przepisu", 267, 357, 192, 124)
GUICtrlCreateLabel("Podaj nazwÄ™ przepisu:", 64, 8, 139, 22)
GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")

$Nazwa = GUICtrlCreateInput("", 0, 32, 265, 21)
GUICtrlCreateLabel("Tutaj daj przepis:", 72, 64, 113, 22)
GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")
$Przepis = GUICtrlCreateEdit("", 0, 88, 265, 225)
GUICtrlSetData(-1, "Przepis")
$Dodaj = GUICtrlCreateButton("Dodaj!", 49, 320, 169, 33)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($GuiDodaj)
            Return
        Case $Dodaj
            GUICtrlSetData($Przepisy, GUICtrlRead($Nazwa) & "|")
            GUIDelete($GuiDodaj)
            Return

    EndSwitch
WEnd

EndFunc

I have problem, function dodaj() - Works.

But only once, when I want to re-use function "dodaj" it does not work anymore, what's the problem?

@edit

Fixed, must rename button ;x

Edited by Bumek662
Link to comment
Share on other sites

Hi,

Fixed, must rename button ;x

In this case you see it's better to declare your variables, the $Dodaj is declared by Default in the global scope here so when you create another button with the same var it will be replaced. Hence the first one not working anymore.

I will reply to your 2nd topic with a cleaned code.

Br, FireFox.

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