Sign in to follow this  
Followers 0
Terenz

Modify the $GUI_EVENT_MAXIMIZE

14 posts in this topic

Hi guys,

Pratically i want to remove/override the classic "maximize" feature ( so make the GUI fullscreen ) and make one custom by me. Maybe there is some event i need to register or something like that? Please provide an example, thanks

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

$hGUI = GUICreate("Form1", 300, 200, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MAXIMIZE
            ; ???
    EndSwitch
WEnd

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have partially solved:

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

Opt("GUIEventOptions", 1)
;  = suppress windows behavior on minimize, restore or maximize click button or window resize.
; Just sends the notification.

$hGUI = GUICreate("Form1", 150, 150, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MAXIMIZE
            ConsoleWrite("Maximize" & @CR)
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_MINIMIZE, $hGUI)
        Case $GUI_EVENT_RESTORE
            GUISetState(@SW_RESTORE, $hGUI)
    EndSwitch
WEnd

There is only a problem, the Maximize button never became a Restore button after a click, need a SendMessage?

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

Hi guys,

Pratically i want to remove/override the classic "maximize" feature ( so make the GUI fullscreen ) and make one custom by me.

To do what? Not be able to Maximize? Just have full screen and nothing else? Not sure what you need. I'm going to take a guess here on maybe what you want and give you several options:

1. To JUST have full screen without any title border do this:

GUICreate("Background", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP)

2. If you want it full screen with a border do this:

GUICreate("Background", @DesktopWidth, @DesktopHeight, 0, 0)

Share this post


Link to post
Share on other sites

I want the user is able to click the maximize button but the maximize button do NOT maximize the window but do a custom function


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

and what is that custom function? a simple description would be great.

edit: A simple way to deal with it is put a transparent gif on top of the maximum control that you can tie to the parent window as a child then assign an action when clicked.

Edited by Bert

Share this post


Link to post
Share on other sites

WinMove and other things but the problem, i'll repeat, is the button. After i have make the Func() the Maximize button don't became a restore button. I think there is a sendmessage or things like that for change the button from maximize to restore, because Windows do it with the default event


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Sigh...I gave you the answer. It is pretty straight forward. You are looking at this from you want to click on the max control to do something different. STOP THAT. Do what I said. Put a small transparent gif to act as a child on TOP of the max control so you CAN'T click on the max control. (you are preventing that from happening). When the user clicks on what they think is the control they are clicking on the gif. You simply make an action to happen when they click the gif. VERY SIMPLE.

You can do this with anything on the screen to keep users from doing stuff you don't want or changing the default behavior of a control. 

Edited by Bert

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

STOP THAT. Do what I said.

 

Yeah, probably in another dimension i'd heard you but I was sure that it was possible, i have not given up like your suggestion, and in fact is so. Maybe you can learn something today Mr.MVP...use a gif LOL :D

; Terenz Original Post!
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>

Opt("GUIEventOptions", 1)
; suppress windows behavior on minimize, restore or maximize click button or window resize.
; Just sends the notification.

$hGUI = GUICreate("Form1", 150, 150, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MAXIMIZE
            $aPos = WinGetPos($hGUI)
            Local $iStyle = _WinAPI_GetWindowLong($hGUI, $GWL_STYLE)
            _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitOR($iStyle, $WS_MAXIMIZE))
            _WinAPI_SetWindowPos($hGUI, $HWND_TOP, $aPos[0], $aPos[1], $aPos[2], $aPos[3], $SWP_SHOWWINDOW)
            ConsoleWrite("Maximize" & @CR)
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_MINIMIZE, $hGUI)
        Case $GUI_EVENT_RESTORE
            If BitAND(WinGetState($hGUI), 16) = 16 Then ; is minimized
                GUISetState(@SW_RESTORE, $hGUI)
            Else
                $aPos = WinGetPos($hGUI)
                Local $iStyle = _WinAPI_GetWindowLong($hGUI, $GWL_STYLE)
                _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitXOR($iStyle, $WS_MAXIMIZE))
                _WinAPI_SetWindowPos($hGUI, $HWND_TOP, $aPos[0], $aPos[1], $aPos[2], $aPos[3], $SWP_SHOWWINDOW)
            EndIf
            ConsoleWrite("Restored" & @CR)
    EndSwitch
WEnd
Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

Terenz,

Very clever. :thumbsup:

I find that using $SWP_SHOWWINDOW in the _WinAPI_SetWindowPos call gives me a better result - the title bar of the GUI does not redraw correctly for me with $SWP_DRAWFRAME. And you will need to work out how to restore the GUI if it is minimized - at present it is irreversible. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Terenz,

And here is how you might do it: :)

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

Opt("GUIEventOptions", 1)

Global $bMinimize_Flag = False

$hGUI = GUICreate("Form1", 450, 450, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MAXIMIZE
            $aPos = WinGetPos($hGUI)
            $iStyle = _WinAPI_GetWindowLong($hGUI, $GWL_STYLE)
            _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitOR($iStyle, $WS_MAXIMIZE))
            _WinAPI_SetWindowPos($hGUI, $HWND_TOP, $aPos[0], $aPos[1], $aPos[2], $aPos[3], $SWP_SHOWWINDOW)
            ConsoleWrite("Maximize" & @CR)
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_MINIMIZE, $hGUI)
            Opt("GUIEventOptions", 0)
            $bMinimize_Flag = True
        Case $GUI_EVENT_RESTORE
            If $bMinimize_Flag Then
                $bMinimize_Flag = False
                Opt("GUIEventOptions", 1)
            Else
                $aPos = WinGetPos($hGUI)
                $iStyle = _WinAPI_GetWindowLong($hGUI, $GWL_STYLE)
                _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitXOR($iStyle, $WS_MAXIMIZE))
                _WinAPI_SetWindowPos($hGUI, $HWND_TOP, $aPos[0], $aPos[1], $aPos[2], $aPos[3], $SWP_SHOWWINDOW)
                ConsoleWrite("Restored" & @CR)
            EndIf
    EndSwitch
WEnd
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Melba,

Thanks, i didn't notice about the minimize problem. I have resolved that, i have removed the WinGetPos and i have replaced $SWP_DRAWFRAME with BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE)

Check it out if is better or i'll use also add the $SWP_SHOWWINDOW to the BitOR

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

Terenz,

Same problem as before - the GUI title bar does not redraw correctly for me. The title moves slightly on the bar and the top corners of the GUI become square - although the latter can be cured by simply moving the GUI. :(>

Adding $SWP_SHOWWINDOW to the other parameters gives the same result - it is only when that parameter is used alone that I get the GUI redrawing with no changes other than the button. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Yeah, probably in another dimension i'd heard you but I was sure that it was possible, i have not given up like your suggestion, and in fact is so. Maybe you can learn something today Mr.MVP...use a gif LOL :D

; Terenz Original Post!
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <WinAPI.au3>

Opt("GUIEventOptions", 1)
; suppress windows behavior on minimize, restore or maximize click button or window resize.
; Just sends the notification.

$hGUI = GUICreate("Form1", 150, 150, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_MAXIMIZE
            Local $iStyle = _WinAPI_GetWindowLong($hGUI, $GWL_STYLE)
            _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitOR($iStyle, $WS_MAXIMIZE))
            _WinAPI_SetWindowPos($hGUI, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
            ConsoleWrite("Maximize" & @CR)
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_MINIMIZE, $hGUI)
        Case $GUI_EVENT_RESTORE
            If BitAND(WinGetState($hGUI), 16) = 16 Then ; is minimized
                GUISetState(@SW_RESTORE, $hGUI)
            Else
                Local $iStyle = _WinAPI_GetWindowLong($hGUI, $GWL_STYLE)
                _WinAPI_SetWindowLong($hGUI, $GWL_STYLE, BitXOR($iStyle, $WS_MAXIMIZE))
                _WinAPI_SetWindowPos($hGUI, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
            EndIf
            ConsoleWrite("Restored" & @CR)
    EndSwitch
WEnd

More than one approach and nice way to solve it! Coding is an art and a dark art at that. When you last posted I was not thinking of the approach you had. I did learn something today. Thanks! :)

Share this post


Link to post
Share on other sites

@Melba Done, replaced with only $SWP_SHOWWINDOW

@Bert You are welcome ;)
 


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0