Jump to content

Recommended Posts

  • Moderators
Posted

mike2003,

Opt("GUICloseOnESC", 0) should do the trick.

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

 

Posted

Maybe you can use $GUI_EVENT_MINIMIZE in your main loop, or use GUIRegisterMsg with WM_SYSCOMMAND, for example :

#Include <GUIConstantsEx.au3>
#Include <WindowsConstants.au3>
#Include <MenuConstants.au3>

Opt("GUICloseOnESC", 0) 
Local $hGui = GUICreate("My GUI")
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd


Func WM_SYSCOMMAND($hWndGUI, $MsgID, $WParam, $LParam)
    Switch $WParam
        Case $SC_MINIMIZE
            MsgBox(0, "", "Minimize button was clicked", 0, $hGui)
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

 

  • Moderators
Posted

mike2003,

Perhaps this is close to what you require:

#Include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TrayConstants.au3>

Opt("GUICloseOnESC", 0)
Opt("GUIEventOptions", 1)

Opt("TrayMenuMode", 3)

$cTrayShow = TrayCreateItem("Restore GUI")
TrayItemSetState($cTrayShow, $TRAY_DISABLE)
TrayCreateItem("")
$cTrayExit = TrayCreateItem("Exit")

Local $hGui = GUICreate("My GUI", 500, 500, Default, Default, BitOr($WS_SYSMENU, $WS_CAPTION))
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            WinSetState($hGui, "", @SW_MINIMIZE)
            TrayItemSetState($cTrayShow, $TRAY_ENABLE)
    EndSwitch

    Switch TrayGetMsg()
        Case $cTrayExit
            Exit
        Case $cTrayShow
            WinSetState($hGui, "", @SW_RESTORE)
            TrayItemSetState($cTrayShow, $TRAY_DISABLE)
    EndSwitch
WEnd

The [X] minimises the GUI and the tray menu restores it. Please ask if you have any questions.

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

 

Posted

@Melba23 I always liked programs that use that feature (minimize to systray) and additionally hide the taskbar icon as well.  This can be achieved by changing @SW_MINIMIZED to @SW_HIDE in your demo script.  I'm sure you knew that...just wanted to point it out for other readers.

Posted (edited)

I think you misunderstood me. Now button ESC does not close the window, but I want to make it minimized when ESC press.

Something like

$GUI_EVENT_CLOSE

but for minimize for ESC )

 

Edited by mike2003
  • Moderators
Posted

mike2003,

To do that I would use an Accelerator key - like this:

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

Local $hGui = GUICreate("My GUI", 500, 500, Default, Default, BitOR($WS_SYSMENU, $WS_CAPTION))

$cMinimiseDummy = GUICtrlCreateDummy()

Local $aAccelKeys[1][2] = [["{ESC}", $cMinimiseDummy]]
GUISetAccelerators($aAccelKeys)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cMinimiseDummy
            WinSetState($hGui, "", @SW_MINIMIZE)
    EndSwitch
WEnd

spudw2k,

I did know about @SW_HIDE removing the icon from the taskbar, but thanks for reminding others.

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

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...