Jump to content

$GUI_EVENT_CLOSE is killing me


Sl4yer
 Share

Recommended Posts

why does nothing happen when the X(close button) on the right-top corner of the window $resWnd is clicked??? pls help cause i spent hours to figure it out :)

$resWnd = GUICreate ("Suchergebnis", 400, $resWndSize, -1 , -1)
                        
                        $reslistView = GuiCtrlCreateListView("Dateiname             |Pfad                 ", -1, -1, 350, 60)
                        
                        For $i = 1 to $aArray[0]
                        
                            $checkArrayCont = StringRegExp($aArray[$i], $dateisuche & "\\", 1, 0)
                            
                            If $checkArrayCont = 1 Then
                                
                                $pathStartPos = StringInStr ($aArray[$i], $dateisuche & "\", 0, -1)
                                $pathEndPos = StringInStr ($aArray[$i], "\", 0, -1)
                                $countPathChars = $pathEndPos - $pathStartPos
                                Dim $extractPath = StringMid ($aArray[$i], $pathStartPos, $countPathChars)

                                $ListViewItemcontrolID = GuiCtrlCreateListViewItem($aArray[$i] & "|" & $extractPath, $reslistView)
                            EndIf

                        Next                        

                        GUISetState(@SW_SHOW, $resWnd)

                        GUISwitch($resWnd)

                        While 1
                            $msg2 = GUIGetMsg(1)

                            If $msg2[0] = $GUI_EVENT_CLOSE AND $msg2[1] = $resWnd Then
                                GuiDelete($resWnd)
                                ExitLoop
                            EndIf

                                                        local $getCurSelection = _GUICtrlListViewGetCurSel($reslistView)

                            If _GUICtrlListViewGetCurSel($reslistView) = 1 Then
                                $curSelectedItemText = _GUICtrlListViewGetItemText($reslistView, _GUICtrlListViewGetSelectedIndices($reslistView), 1)
                                
                                If ($curSelectedItemText <> "") Then
                                    RunWait(@ComSpec & ' /c explorer "' & $curSelectedItemText & '\"', "", @SW_HIDE)
                                EndIf

                                _GUICtrlListViewSetItemSelState ($reslistView, _GUICtrlListViewGetSelectedIndices($reslistView), 0, 0)

                            EndIf
                        WEnd
Link to comment
Share on other sites

your code is not complete and also with bad order, Replace with this it works!

While 1
    $msg2 = GUIGetMsg()
    Switch $msg2
    Case $GUI_EVENT_CLOSE
        GUIDelete($resWnd)
        ExitLoop
    EndSwitch
WEnd
Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, ‘What happened?’” –Casey Stengel
Link to comment
Share on other sites

your code is not complete and also with bad order, Replace with this it works!

While 1
    $msg2 = GUIGetMsg()
    Switch $msg2
    Case $GUI_EVENT_CLOSE
        GUIDelete($resWnd)
        ExitLoop
    EndSwitch
WEnd
hey Chrome,

what do u mean with "my code is not complete" ??

I tried ur solution but it DOESNT work :)

im about to go nuts >_<

Link to comment
Share on other sites

hey Chrome,

what do u mean with "my code is not complete" ??

I tried ur solution but it DOESNT work :)

im about to go nuts >_<

Your code is disordered, please correct it or tidy it. also post full code. where did you replace yours with mine?

Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, ‘What happened?’” –Casey Stengel
Link to comment
Share on other sites

don't use mine code in Function and place it under GUI Commands. just do something like this while creating GUI.

#include <GUIConstants.au3>
$F1 = GUICreate("Step1", 406, 450, 195, 114)
$P1 = GUICtrlCreatePic("fff.jpg", 0, 0, 404, 404)
$B1 = GUICtrlCreateButton("Yes", 48, 416, 75, 25, 0)
$B2 = GUICtrlCreateButton("No", 248, 416, 75, 25, 0)
GUISetState(@SW_SHOW)
While 1
    $Get = GUIGetMsg()
    Switch $Get
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Use "Case" instead of "If" it will enhance it's speed.

Edited by ChromeFan
Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, ‘What happened?’” –Casey Stengel
Link to comment
Share on other sites

don't use mine code in Function and place it under GUI Commands. just do something like this while creating GUI.

#include <GUIConstants.au3>
$F1 = GUICreate("Step1", 406, 450, 195, 114)
$P1 = GUICtrlCreatePic("fff.jpg", 0, 0, 404, 404)
$B1 = GUICtrlCreateButton("Yes", 48, 416, 75, 25, 0)
$B2 = GUICtrlCreateButton("No", 248, 416, 75, 25, 0)
GUISetState(@SW_SHOW)
While 1
    $Get = GUIGetMsg()
    Switch $Get
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Use "Case" instead of "If" it will enhance it's speed.

sry Chrome but i dont get it??

did u figure it out, the problem why the window $resWnd cant be closed???

ps: i know that switch is kinda faster than the if statement but thats not my problem...

Link to comment
Share on other sites

Your problem is due to the fact that you are mixing OnEvent mode and Message mode together. When Opt("GUIOnEventMode", 1) is in force GUIGetMsg(1) will always return 0 and sets @error to 1.

This quick fix will get your code working

Func DButton()
Opt("GUIOnEventMode", 0) ; Turn event mode off

:Your function code goes here

Opt("GUIOnEventMode", 1)  ; Turn event mode back on
EndFunc   ;==>DButton

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

hmmm your problem is now solved, it will not kill you now :)

Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, ‘What happened?’” –Casey Stengel
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...