Jump to content
Sign in to follow this  
qwert

[Solved] Seeking resize method that doesn't require frame

Recommended Posts

qwert

In 2014, KaFu posted an interesting solution for resizing a GUI that avoids the flashing that results from refreshes during a drag operation ... without having to get involved with managing the refreshes of displayed elements (as other methods attempt to do).  He simply switches off the windows update mode and switches it back on after the resize.

This method works great for one of my screens, but it requires a frame around the GUI ... which my screen doesn't normally have (it's a popup window).

I've put together a working prototype and would like to ask: how can I add a drag handle at the bottom of the screen and eliminate the frame?

And I want to emphasize that point: I only want a handle at the bottom, since my GUI only makes sense when it's extended downward.

#include <GUIConstants.au3>

$SC_MOVE = 0xF010
$SC_SIZE = 0xF000
Global $i_DRAGFULLWINDOWS_Current
Global $i_DRAGFULLWINDOWS_Initial = _SPI_GETDRAGFULLWINDOWS()

OnAutoItExitRegister("_Reset_DRAGFULLWINDOWS")
$hGUI = GUICreate("GUI", 200, 200, -1, -1, $WS_SIZEBOX + $WS_POPUP)
GUICtrlCreateLabel("DRAG HANDLE", 60, 40, 100, 24, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip ( -1, "You may drag the GUI" & @CRLF & "using this upper area")
GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Exit = GUICtrlCreateButton("Exit", 50, 90, 100, 21)
GUICtrlSetResizing(-1, $GUI_DOCKALL)

GUICtrlCreateLabel(" |   |      need to extend, only      |   |", 20, 170, 170, 22, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
GUICtrlCreateLabel("V V", 20, 180, 32, 22)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
GUICtrlCreateLabel("V V", 166, 180, 32, 22)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)

GUIRegisterMsg($WM_ENTERSIZEMOVE, "WM_ENTERSIZEMOVE")
GUIRegisterMsg($WM_EXITSIZEMOVE, "WM_EXITSIZEMOVE")
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

GUISetState()

While 1
    $nMsg = GUIGetMsg()                                     ; AGAIN, OUR STANDARD METHOD
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Exit
            Exit
    EndSwitch
WEnd

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    Switch BitAND($wParam, 0xFFF0)
        Case $SC_MOVE, $SC_SIZE
        $i_DRAGFULLWINDOWS_Current = _SPI_GETDRAGFULLWINDOWS()
        DllCall("user32.dll", "int", "SystemParametersInfo", "int", 37, "int", 0, "ptr", 0, "int", 2)
    EndSwitch
EndFunc   ;==>On_WM_SYSCOMMAND

Func WM_EXITSIZEMOVE()
    DllCall("user32.dll", "int", "SystemParametersInfo", "int", 37, "int", $i_DRAGFULLWINDOWS_Current, "ptr", 0, "int", 2)
EndFunc   ;==>WM_EXITSIZEMOVE

Func WM_ENTERSIZEMOVE($hWnd, $Msg, $wParam, $lParam)
    If $hWnd = $hGUI Then $moving = True
    Return "GUI_RUNDEFMSG"
EndFunc

Func _SPI_GETDRAGFULLWINDOWS()
    $tBool = DllStructCreate("int")
    DllCall("user32.dll", "int", "SystemParametersInfo", "int", 38, "int", 0, "ptr", DllStructGetPtr($tBool), "int", 0)
    Return DllStructGetData($tBool, 1)
EndFunc   ;==>_SPI_GETDRAGFULLWINDOWS

Func _Reset_DRAGFULLWINDOWS()
DllCall("user32.dll", "int", "SystemParametersInfo", "int", 37, "int", $i_DRAGFULLWINDOWS_Initial, "ptr", 0, "int", 2)
EndFunc   ;==>_Reset_DRAGFULLWINDOWS

Thanks for any suggestions.

 

Edited by qwert

Share this post


Link to post
Share on other sites
qwert

I've been trying a couple of things ... without success.  So I'm looking at another alternative.

If I have the user click on the word 'extend', then how can I extend the GUI vertically by 50% (for example) so that all of the elements follow the docking rules assigned to them?

It would respond as if the user had used the frame's drag handle, but there wouldn't be a frame ... and there wouldn't be any refresh issues.  The GUI would simply upsize upon command ... and the word 'extend' could then be an 'upsize button' somewhere on the GUI.  A main point is that the docking rules keep everything in their proper positions.

But, how to go about this?  I haven't been able to locate an example of anything similar.

 

Share this post


Link to post
Share on other sites
BrewManNH

 

17 minutes ago, qwert said:

If I have the user click on the word 'extend', then how can I extend the GUI vertically by 50% (for example) so that all of the elements follow the docking rules assigned to them?

Have you tried WinMove?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
qwert

Well, I have now!  And it does exactly what I need.  (My working result—rid of all the registered functions!—is shown below, for others to follow.)

I've used WinMove for exactly what it says ... but never considered the effects of resizing (and not moving).

This is a perfect example of being too close to the problem.  You wouldn't believe the things I've been trying.

Thank you!

 

#include <GUIConstants.au3>

$hGUI = GUICreate("GUI", 200, 200, -1, -1, $WS_POPUP)
GUICtrlCreateLabel("DRAG HANDLE", 60, 10, 100, 30, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetTip ( -1, "You may drag the GUI" & @CRLF & "using this upper area")
GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Extend = GUICtrlCreateButton("Extend", 50, 40, 100, 21)
GUICtrlSetResizing(-1, $GUI_DOCKALL)

$Exit = GUICtrlCreateButton("Exit", 50, 80, 100, 21)
GUICtrlSetResizing(-1, $GUI_DOCKALL)

GUICtrlCreateLabel(" |   |      need to extend, only      |   |", 20, 170, 170, 22, -1, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
GUICtrlCreateLabel("V V", 20, 180, 32, 22)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
GUICtrlCreateLabel("V V", 166, 180, 32, 22)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Exit
            Exit
    Case $Extend
        Local $aPos = WinGetPos($hGUI)
        WinMove($hGUI, "", $aPos[0], $aPos[1], $aPos[2], 300)
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
BrewManNH

I wasn't 100% sure it would work and keep the docking information, but I'm glad it worked as you wanted.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

×