Jump to content

Guidelete problems


dansxmods
 Share

Recommended Posts

Hi all,

Is anybody else having problems with guidelete in the latest version of autoit, or am i using it in the wrong way.

Func _close_about()
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00050004)
    GUISetState(@SW_HIDE, $Form1)
    GUIDelete()
    GUISetState(@SW_SHOW, $input_gui)
    _WinAPI_RedrawWindow($input_gui)
EndFunc;==> _close_about()
Link to comment
Share on other sites

  • Moderators

@dansxmods,

I have no problems at all with GUIDelete in 3.3.0.0. Have you tried the code without hiding the window first and deliberately specifying the ID? That has worked for me in the past, and still does:

Func _close_about()
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00050004)
    GUIDelete($Form1)
    GUISetState(@SW_SHOW, $input_gui)
    _WinAPI_RedrawWindow($input_gui)
EndFunc;==> _close_about()

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

also why do you need to use guidelete unless your doing something other than making it invisible... @SW_HIDE does that and if im correct onautoitexit delets the gui on exit so yeah idk

Link to comment
Share on other sites

I think it is how I am using it I tried @sw_hide but it doesn't hide the title in the taskbar. I also tried not using the @sw_hide and specifying the id but it still crashes my script. It still doesn't work with the previous version of autoit either. Thanks for your advice but the problem still remains.

It still works if I put it within the function that create the gui. Then I tried putting an if then else in there but that then causes it to crash.

Edited by dansxmods
Link to comment
Share on other sites

ok then maybe you should try and make your gui a toolwindow and always ontop, then have it minimize\maximise by a hotkey then try @SW_HIDE thats what i would do

Link to comment
Share on other sites

Hi all,

Is anybody else having problems with guidelete in the latest version of autoit, or am i using it in the wrong way.

Func _close_about()
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Form1, "int", 200, "long", 0x00050004)
    GUISetState(@SW_HIDE, $Form1)
    GUIDelete()
    GUISetState(@SW_SHOW, $input_gui)
    _WinAPI_RedrawWindow($input_gui)
EndFunc;==> _close_about()
Works fine for me:

#include <GuiConstantsEx.au3>

Global $hGUI = GUICreate("Test", 300, 200)

GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hGUI, "int", 200, "long", 0x00050004)
GUISetState(@SW_HIDE, $hGUI)
GUIDelete($hGUI)

Maybe GUIDelete($Form1)? Or make a small example to represent your problem.

Link to comment
Share on other sites

Can somebody give this a try and see if it crashes on them.

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>

Global $sample, $label
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
Func _open_gui()
    $sample = GUICreate("Hello", -1, -1, -1, -1)
    $label = GUICtrlCreateLabel("Click on me", 20, 40, -1, -1, $SS_CENTER)
    $button = GUICtrlCreateButton("Or click here", 20, 80)
    
    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
        Case $msg = $gui_event_close
            Exit
        Case $msg = $button
            _delete_gui()
            Exit
        EndSelect       
    WEnd
    
EndFunc

Func _delete_gui()
    GUIDelete($sample)
EndFunc

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Switch $iwParam
        case $label
            _delete_gui()
;~          MsgBox(0,"test","test")
;~          Exit
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc
_open_gui()

Am I using the GUIRegisterMsg incorrectly.

EDIT:

Made a better example. Clicking on the label causes it to crash.

Edited by dansxmods
Link to comment
Share on other sites

@dansxmods

Clicking on the label causes it to crash

Crash? Clicking on the label causes the GUI deleting:

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>

Global $sample, $label

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

_open_gui()

Func _open_gui()
    $sample = GUICreate("Hello", -1, -1, -1, -1)
    $label = GUICtrlCreateLabel("Click on me", 20, 40, -1, -1, $SS_CENTER)
    $button = GUICtrlCreateButton("Or click here", 20, 80)

    GUISetState()
    
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $gui_event_close
                Exit
            Case $msg = $button
                _delete_gui()
                Exit
        EndSelect
    WEnd

EndFunc   ;==>_open_gui

Func _delete_gui()
    GUIDelete($sample)
EndFunc   ;==>_delete_gui

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Switch $iwParam
        Case $label
            _delete_gui()
            Exit
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

:)

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