ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


3 posters

    ผมปัญหากับการปิด Form

    max30012540
    max30012540
    PSsix Member High Class
    PSsix Member High Class


    ผมปัญหากับการปิด Form  Empty PSsix Program Coder
    จำนวนข้อความ : 98
    ความนิยม : 10
    เข้าร่วมเมื่อ : 10/10/2011
    อายุ : 26

    ผมปัญหากับการปิด Form  Empty ผมปัญหากับการปิด Form

    ตั้งหัวข้อ by max30012540 25/10/11, 11:54 am

    ผมปัญหากับการปิด Form ครับ โดยผมจะให้โปรแกรมของผมนั้นทำงานโดย เมื่อเปิดขึ้นมาจะขึ้น Form1 และ เมื่อกด Button1 Form2 จะแสดงขึ้น และเมื่อปิด Form2 แล้ว Form1 จะยังคงอยู่ครับ Autoit พอจะทำได้ไหมครับ

    Code:
    #include <GUIConstants.au3>

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("โปรแกรมคำนวน W", 290, 211, 625, 200)
    $Button1 = GUICtrlCreateButton("อยากทำแอมป์กี่ วัตต์ กี่โอม", 72, 48, 145, 33, 0)
    $Button2 = GUICtrlCreateButton("หม้อแปลงทำขยายได้กี่วัตต์", 72, 88, 145, 33, 0)
    $Button3 = GUICtrlCreateButton("DC เป็น AC", 72, 128, 145, 33, 0)
    $Button4 = GUICtrlCreateButton("ต้องการทำWจริงของคลาส AB", 72, 168, 145, 33, 0)
    $Label1 = GUICtrlCreateLabel("สูตรคำนวนโดย tv_2007 แห่ง Un-sound.com", 40, 8, 213, 17)
    $Label2 = GUICtrlCreateLabel("จัดทำโปรแกรมโดย เด็กรักเครื่องเสียง แห่ง Un-sound.com", 8, 24, 276, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


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

          Case  $Button2
             TW()

          Case  $Button3
             DCTOAC()

          Case  $Button4
             WYes()

       EndSwitch
    WEnd

    Func AMPWH()
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("อยากทำแอมป์กี่ W กี่ โอห์ม", 291, 178, 289, 287)
    $Button5 = GUICtrlCreateButton("คำนวน", 64, 136, 161, 33, 0)
    $Label3 = GUICtrlCreateLabel("ต้องการทำแอมป์(W)", 64, 8, 97, 17)
    $Input1 = GUICtrlCreateInput("1667", 64, 24, 161, 21)
    $Label4 = GUICtrlCreateLabel("กี่โอห์ม", 64, 48, 36, 17)
    $Input2 = GUICtrlCreateInput("8", 64, 64, 161, 21)
    $Label5 = GUICtrlCreateLabel("กำลัง W ของ TR Out Put", 64, 88, 118, 17)
    $Input3 = GUICtrlCreateInput("150", 64, 104, 161, 21)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


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

          Case $Button5
             $VDC1 = GUICtrlRead($Input1) * GUICtrlRead($Input2) *2
             $VDC2 = $VDC1^0.5
             MsgBox(4096, "Vdc=", "ต้องใช้ไฟ Vdc="&$VDC2)
             $VAC1 = $VDC2 / 1.414
             MsgBox(4096, "Vac=", "ต้องใช้ไฟ Vac="&$VAC1)
             $A1 = GUICtrlRead($Input1) / GUICtrlRead($Input2)
             $A2 = $A1 ^0.5
             MsgBox(4096, "A=", "กระแส="&$A2)
             $VA1 = $VAC1 + $VAC1
             $VA2 = $VA1 * $A2
             MsgBox(4096, "VA=", "VA="&$VA2)
             $ASO1 = $A2 *2
             MsgBox(4096, "ASO=", "ทำเป็นstereo ต้องใช้กระแส="&$ASO1)
             $ATR1 = $A2 /2
             MsgBox(4096, "ATR=", "จ่ายกระแสให้ TR out put ต่อ 1 ข้าง(+)="&$ATR1)
             MsgBox(4096, "ATR=", "จ่ายกระแสให้ TR out put ต่อ 1 ข้าง(-)="&$ATR1)
             $TROUT1 = $VDC2 *2
             $TROUT2 = GUICtrlRead($Input3) / $TROUT1
             MsgBox(4096, "TROUT=", "กระแสไหลผ่าน TR out put ต่อ 1 ตัว="&$TROUT2)
             $NTR1 = $ATR1 / $TROUT2
             MsgBox(4096, "NTR=", "ต้องใช้ TR out put (+) จำนวน="&$NTR1)
             MsgBox(4096, "NTR=", "ต้องใช้ TR out put (-) จำนวน="&$NTR1)
             $AB1 = GUICtrlRead($Input1) * 0.6
             MsgBox(4096, "AB60%=", "ประสิทธิภาพคลาส AB ไม่เกิน 60% จะได้="&$AB1)
             $SPH1 = GUICtrlRead($Input2)
             $SPW1 = $AB1 + 50
             MsgBox(4096, "SPH=", "ดอกลำโพงที่ต้องใช้(โอห์ม)="&$SPH1)
             MsgBox(4096, "SPW=", "ดอกลำโพงที่ต้องใช้(W)="&$SPW1)

       EndSwitch
    WEnd
    EndFunc


    Func TW()
       #Region ### START Koda GUI section ### Form=
    $Form3 = GUICreate("หม้อแปลงทำขยายได้กี่วัตต์", 291, 141, 623, 240)
    $Label6 = GUICtrlCreateLabel("มีหม้อแปลง(Vac)", 40, 8, 84, 17)
    $Input4 = GUICtrlCreateInput("115.5", 40, 24, 209, 21)
    $Label7 = GUICtrlCreateLabel("โหลดที่(โอห์ม)", 40, 48, 67, 17)
    $Input5 = GUICtrlCreateInput("8", 40, 64, 209, 21)
    $Button6 = GUICtrlCreateButton("คำนวน", 80, 96, 137, 33, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $Button6
             $VDC3 = GUICtrlRead($Input4) * 1.414
             $VDC4 = $VDC3  * $VDC3
             $VDC5 = GUICtrlRead($Input5) * 2
             $VDC6 = $VDC4  /  $VDC5
             MsgBox(4096, "ABW=", "ทำแอมป์ AB ได้(W)="&$VDC6)
             $AT1 = $VDC6 / GUICtrlRead($Input5)
             $AT2 = $AT1 ^ 0.5
             MsgBox(4096, "AT=", "กระแสที่ต้องใช้(A)="&$AT2)

       EndSwitch
    WEnd
    EndFunc


    Func DCTOAC()
       #Region ### START Koda GUI section ### Form=
    $Form3 = GUICreate("DC เป็น AC", 291, 115, 409, 221)
    $Label7 = GUICtrlCreateLabel("ไฟ DC(VDC)", 32, 8, 66, 17)
    $Input6 = GUICtrlCreateInput("163.3", 32, 24, 225, 21)
    $Button7 = GUICtrlCreateButton("คำนวน", 72, 64, 145, 33, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $Button7
             $VAC3= GUICtrlRead($Input6) /1.414
             MsgBox(4096, "Vac=", "ไฟ AC(VAC)="&$VAC3)

       EndSwitch
    WEnd
    EndFunc

    Func WYes()
       #Region ### START Koda GUI section ### Form=
    $Form4 = GUICreate("ต้องการทำWจริงของคลาส AB", 291, 115, 409, 221)
    $Label8 = GUICtrlCreateLabel("จะได้ กำลังวัตต์ที่ 100%",  32, 8, 200, 17)
    $Input7 = GUICtrlCreateInput("1000", 32, 24, 225, 21)
    $Button8 = GUICtrlCreateButton("คำนวน", 72, 64, 145, 33, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $Button8
             $WONE = GUICtrlRead($Input7) /0.6
             MsgBox(4096, "Vac=", "จะได้ กำลังวัตต์ที่ 100%(W)="&$WONE)

       EndSwitch
    WEnd
    EndFunc
    asokura
    asokura
    PSsix Member High Class
    PSsix Member High Class


    PSsix Game Coder
    จำนวนข้อความ : 72
    ความนิยม : 11
    เข้าร่วมเมื่อ : 03/09/2011

    ผมปัญหากับการปิด Form  Empty Re: ผมปัญหากับการปิด Form

    ตั้งหัวข้อ by asokura 25/10/11, 03:20 pm

    พอดีเจอตัวอย่าง คิดว่าน่าจะเป็นแบบที่ท่านต้องการน๊ะครับ

    Code:
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    Opt('MustDeclareVars', 1)

    form1()

    Func form1()
        Local $msg, $Button_1, $Button_0, $form1, $form2, $aGuiPos
        $form1 = GUICreate("form1")
        $Button_0 = GUICtrlCreateButton("Form2", 20, 10, 100)
        GUISetState()

        While 1
            $msg = GUIGetMsg()
            Switch $msg
                Case $GUI_EVENT_CLOSE
                    If WinExists("form2") = 1 And BitAND(WinGetState("form2"), 8) Then
                        GUIDelete($form2)
                    ElseIf WinExists("form1") = 1 And BitAND(WinGetState("form1"), 8) Then ;
                    EndIf
                Case $Button_0
                    If WinExists("form2") <> 1 Then
                        $form2 = GUICreate("form2")
                        $Button_1 = GUICtrlCreateButton("close", 20, 10, 100)
                        GUISwitch($form2)

                        $aGuiPos = WinGetPos("form2")
                        WinMove("form2", "", $aGuiPos[0] + 200, $aGuiPos[1] - 100)
                        GUISetState()
                    EndIf
                Case $Button_1
                    If WinExists("form2") = 1 Then GUIDelete($form2)
            EndSwitch

            If WinExists("form2") <> 1 And WinExists("form1") <> 1 Then Exit

        WEnd
    EndFunc

    ที่มา [You must be registered and logged in to see this link.]
    max30012540
    max30012540
    PSsix Member High Class
    PSsix Member High Class


    ผมปัญหากับการปิด Form  Empty PSsix Program Coder
    จำนวนข้อความ : 98
    ความนิยม : 10
    เข้าร่วมเมื่อ : 10/10/2011
    อายุ : 26

    ผมปัญหากับการปิด Form  Empty Re: ผมปัญหากับการปิด Form

    ตั้งหัวข้อ by max30012540 25/10/11, 04:10 pm

    asokura พิมพ์ว่า:พอดีเจอตัวอย่าง คิดว่าน่าจะเป็นแบบที่ท่านต้องการน๊ะครับ

    Code:
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    Opt('MustDeclareVars', 1)

    form1()

    Func form1()
        Local $msg, $Button_1, $Button_0, $form1, $form2, $aGuiPos
        $form1 = GUICreate("form1")
        $Button_0 = GUICtrlCreateButton("Form2", 20, 10, 100)
        GUISetState()

        While 1
            $msg = GUIGetMsg()
            Switch $msg
                Case $GUI_EVENT_CLOSE
                    If WinExists("form2") = 1 And BitAND(WinGetState("form2"), 8) Then
                        GUIDelete($form2)
                    ElseIf WinExists("form1") = 1 And BitAND(WinGetState("form1"), 8) Then ;
                    EndIf
                Case $Button_0
                    If WinExists("form2") <> 1 Then
                        $form2 = GUICreate("form2")
                        $Button_1 = GUICtrlCreateButton("close", 20, 10, 100)
                        GUISwitch($form2)

                        $aGuiPos = WinGetPos("form2")
                        WinMove("form2", "", $aGuiPos[0] + 200, $aGuiPos[1] - 100)
                        GUISetState()
                    EndIf
                Case $Button_1
                    If WinExists("form2") = 1 Then GUIDelete($form2)
            EndSwitch

            If WinExists("form2") <> 1 And WinExists("form1") <> 1 Then Exit

        WEnd
    EndFunc

    ที่มา [You must be registered and logged in to see this link.]

    นั่งดูไป ดูมา แล้ว งง ครับ em228
    max30012540
    max30012540
    PSsix Member High Class
    PSsix Member High Class


    ผมปัญหากับการปิด Form  Empty PSsix Program Coder
    จำนวนข้อความ : 98
    ความนิยม : 10
    เข้าร่วมเมื่อ : 10/10/2011
    อายุ : 26

    ผมปัญหากับการปิด Form  Empty Re: ผมปัญหากับการปิด Form

    ตั้งหัวข้อ by max30012540 25/10/11, 04:34 pm

    เย้ๆๆๆ ที่แท้ก็ใช้ GUIDelete() นี้เอง
    avatar
    Fast
    PSsix Member Super Class III
    PSsix Member Super Class III


    ผมปัญหากับการปิด Form  Empty PSsix Program Coder
    จำนวนข้อความ : 217
    ความนิยม : 54
    เข้าร่วมเมื่อ : 19/06/2011

    ผมปัญหากับการปิด Form  Empty Re: ผมปัญหากับการปิด Form

    ตั้งหัวข้อ by Fast 25/10/11, 04:44 pm

    กำ em234 บอร์ดเราก็มีอ่านไปไม่กี่กระทู้ก็เห็น >> [You must be registered and logged in to see this link.]
    max30012540
    max30012540
    PSsix Member High Class
    PSsix Member High Class


    ผมปัญหากับการปิด Form  Empty PSsix Program Coder
    จำนวนข้อความ : 98
    ความนิยม : 10
    เข้าร่วมเมื่อ : 10/10/2011
    อายุ : 26

    ผมปัญหากับการปิด Form  Empty Re: ผมปัญหากับการปิด Form

    ตั้งหัวข้อ by max30012540 25/10/11, 05:02 pm

    Fast พิมพ์ว่า:กำ em234 บอร์ดเราก็มีอ่านไปไม่กี่กระทู้ก็เห็น >> [You must be registered and logged in to see this link.]
    อ่าว ขออภัยด้วยครับ

      เวลาขณะนี้ 08/05/24, 02:54 am