Jump to content

How To Close A Secound Window With out exiting the old program


Recommended Posts

hello all,

i have a main app window that works grate but i add a seound window to show some information and when i click ok to close the window it exits the hole program. here is my code can some show me were im going wrong please.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
#include <array.au3>
#include "mysql.au3"
#Include <Date.au3>

Global $Name
Global $FullPath
Global $temp = ""
Global $FORMTITLE = ("Product Add To Shop : BIG DEAL GENRAL GOODS.")


;GUI DATA.
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate($FORMTITLE, 468, 400, 208, 126)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1)
$MenuItem2 = GUICtrlCreateMenu("Help")
$MenuItem4 = GUICtrlCreateMenuItem("About", $MenuItem2)
$IMAGE = GUICtrlCreateInput("", 240, 256, 121, 21)
$Label1 = GUICtrlCreateLabel("Title", 56, 24, 24, 17)
$Label2 = GUICtrlCreateLabel("Catorgury", 312, 24, 49, 17)
$Label3 = GUICtrlCreateLabel("Decryption", 32, 88, 55, 17)
$Label4 = GUICtrlCreateLabel("Price £", 272, 88, 36, 17)
$Label5 = GUICtrlCreateLabel("Shipping £", 368, 88, 53, 17)
$Label6 = GUICtrlCreateLabel("URL Link", 272, 160, 49, 17)
$Label7 = GUICtrlCreateLabel("Image", 288, 232, 33, 17)
$TITLE = GUICtrlCreateInput("", 16, 48, 185, 21)
$DEC = GUICtrlCreateEdit("", 16, 120, 209, 249)
GUICtrlSetData(-1, "")
$CATS = GUICtrlCreateCombo("", 264, 48, 145, 25)
GUICtrlSetData(-1, "Bikes|Audio|Clothes|Furniture|House Hold Electrical|House Hold Goods|Textiles|Tools|Kitchen|Beauty|Other")
$PRICE = GUICtrlCreateInput("", 256, 112, 73, 21)
$SHIPPING = GUICtrlCreateInput("", 352, 112, 81, 21)
$ARGOS = GUICtrlCreateInput("", 256, 184, 185, 21)
$Button1 = GUICtrlCreateButton("Browse", 376, 256, 75, 25)
$Button2 = GUICtrlCreateButton("Add Product To Site", 328, 328, 123, 25)

;text that will show home much text can be entered on to a text filed
$Label8 = GUICtrlCreateLabel("100", 88, 24, 56, 17)
$Label11 = GUICtrlCreateLabel("Characters", 112, 24, 55, 17)
$Label9 = GUICtrlCreateLabel("1000", 96, 88, 28, 17)
$Label12 = GUICtrlCreateLabel("Characters", 136, 88, 55, 17)
$Label10 = GUICtrlCreateLabel("250", 336, 160, 22, 17)
$Label13 = GUICtrlCreateLabel("Characters", 364, 160, 55, 17)

;limets how much text can be ented in to a text filed
GUICtrlSetLimit($TITLE, 100)
GUICtrlSetLimit($DEC, 1000)
GUICtrlSetLimit($SHIPPING, 10)
GUICtrlSetLimit($PRICE, 10)
GUICtrlSetLimit($ARGOS, 250)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $MenuItem3
            Exit
        Case $MenuItem4
            #Region ### START Koda GUI section ### Form=
            $Form1 = GUICreate("About", 327, 248, 302, 218)
            GUISetIcon("D:\006.ico")
            $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185)
            $Image1 = GUICtrlCreatePic("", 16, 24, 105, 97)
            $Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP)
            $Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, $WS_GROUP)
            $Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP)
            $Label3 = GUICtrlCreateLabel("Copyright", 16, 136, 48, 17, $WS_GROUP)
            GUICtrlCreateGroup("", -99, -99, 1, 1)
            $Button1 = GUICtrlCreateButton("&OK", 112, 208, 75, 25, 0)
            GUISetState(@SW_SHOW)
            #EndRegion ### END Koda GUI section ###

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

                EndSwitch
            WEnd


        ;Selecting An Image.
        Case $Button1
            $Open = FileOpenDialog("Slect Image", @UserName, "images (*.JPG)")
            Dim $Drive,$Dir,$Name,$Ext
            _PathSplit($Open,$Drive,$Dir,$Name,$Ext)
            $Name=$Name&$Ext
            $Path=$Drive&$Dir
            $FullPath=$Path&$Name
            GUICtrlSetData($IMAGE, $Name, 1)
            ;MsgBox(0,"",$Name)
            ;MsgBox(0,"",$Path)
            ;MsgBox(0,"Full File Path",$FullPath)

        Case $Button2
            $CATS1 = GUICtrlRead($CATS)
            $TITLE1 = GUICtrlRead($TITLE)
            $DEC1 = GUICtrlRead($DEC)
            $PRICE1 = GUICtrlRead($PRICE)
            $SHIPPING1 = GUICtrlRead($SHIPPING)
            $ARGOS1 = GUICtrlRead($ARGOS)
            $DATE1 = _NowDate()

            ;SQL DATA
            ; MYSQL to start, DLL in the PATH (contains) also @ ScriptDir, sont specify a path to the DLL. DLL must be called libmysql.dll.
            _MySQL_InitLibrary()
            If @error Then Exit MsgBox (0,'', "could nit init MySQL")

            $MysqlConn = _MySQL_Init()
            ;connection line
            $connected = _MySQL_Real_Connect($mysqlConn, "localhost", "root", "", "shop")
            If $connected = 0 Then Exit MsgBox (16, 'Connection Error', _MySQL_Error ($mysqlConn))
            ;Insert Line
            $query = "INSERT INTO `goods` (`CATS`, `TITLE`, `DECRYPTION`, `PRICE`, `SHIPPING`, `ARGOS`, `IMAGE`, `DATE`) VALUES ('"&$CATS1&"', '"&$TITLE1&"', '"&$DEC1&"', '"&$PRICE1&"', '"&$SHIPPING1&"', '"&$ARGOS1&"', '"&$Name&"', '"&$DATE1&"')"
            _MySQL_Real_Query($mysqlConn, $query)
            ; Close connection
            _MySQL_Close($MysqlConn)
            ; shutdown MYSQL-library
            _MySQL_EndLibrary()


            MsgBox(0,"Product Addad", "Product Added To Site")

    EndSwitch

    ;count down for the title box
    $entered = GUICtrlRead($TITLE)
    If $entered <> "" And GUICtrlRead($TITLE)<> $temp Then
    $temp = GUICtrlRead($TITLE)
    GUICtrlSetData($Label8, 100- StringLen($temp))
    EndIf

    ;count down for dec box
    $entered2 = GUICtrlRead($DEC)
    If $entered2 <> "" And GUICtrlRead($DEC)<> $temp Then
    $temp = GUICtrlRead($DEC)
    GUICtrlSetData($Label9, 1000- StringLen($temp))
    EndIf

    ;count down for URL box
    $entered3 = GUICtrlRead($ARGOS)
    If $entered3 <> "" And GUICtrlRead($ARGOS)<> $temp Then
    $temp = GUICtrlRead($ARGOS)
    GUICtrlSetData($Label10, 250- StringLen($temp))
    EndIf


WEnd
Link to comment
Share on other sites

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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