Sign in to follow this  
Followers 0
Bumek662

Problem, GuiDelete (?)

2 posts in this topic

#1 ·  Posted (edited)

#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

Share this post


Link to post
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.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0