Terenz Posted November 22, 2014 Posted November 22, 2014 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
Terenz Posted November 22, 2014 Author Posted November 22, 2014 (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 November 22, 2014 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
Bert Posted November 22, 2014 Posted November 22, 2014 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) The Vollatran project My blog: http://www.vollysinterestingshit.com/
Terenz Posted November 22, 2014 Author Posted November 22, 2014 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
Bert Posted November 22, 2014 Posted November 22, 2014 (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 November 22, 2014 by Bert The Vollatran project My blog: http://www.vollysinterestingshit.com/
Terenz Posted November 22, 2014 Author Posted November 22, 2014 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
Bert Posted November 22, 2014 Posted November 22, 2014 (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 November 22, 2014 by Bert The Vollatran project My blog: http://www.vollysinterestingshit.com/
Solution Terenz Posted November 22, 2014 Author Solution Posted November 22, 2014 (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 expandcollapse popup; 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 November 22, 2014 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
Moderators Melba23 Posted November 22, 2014 Moderators Posted November 22, 2014 Terenz,Very clever. 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Moderators Melba23 Posted November 22, 2014 Moderators Posted November 22, 2014 Terenz,And here is how you might do it: expandcollapse popup#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 WEndM23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Terenz Posted November 22, 2014 Author Posted November 22, 2014 (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 November 22, 2014 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength
Moderators Melba23 Posted November 22, 2014 Moderators Posted November 22, 2014 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Bert Posted November 22, 2014 Posted November 22, 2014 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 ; 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 WEndMore 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! The Vollatran project My blog: http://www.vollysinterestingshit.com/
Terenz Posted November 22, 2014 Author Posted November 22, 2014 @Melba Done, replaced with only $SWP_SHOWWINDOW @Bert You are welcome Nothing is so strong as gentleness. Nothing is so gentle as real strength
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now