Sign in to follow this  
Followers 0
leomoon

Problem with Resizeable GUI

5 posts in this topic

Hello,

I'm having a little bit of problem with making a resizeable GUI. In this GUI there are two GUICtrlEdits top to bottom with about 12 pixels apart from each other. I want the top GUICtrlEdit to be pinned @ 38 from top and the bottom GUICtrlEdit to be pinned @ 8 from bottom. Now when I maximize the top GUICtrlEdit is pinned at top and the bottom GUICtrlEdit is pinned at bottom correctly but the 12 pixels space between them gets bigger.

This is the code I have:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $mainGuiW = 410, $mainGuiH = 202
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", $mainGuiW, $mainGuiH, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Edit1 = GUICtrlCreateEdit("", 8, 8+30, 393, $mainGuiH/2-30, BitOR($ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "Edit1")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP)
$Edit2 = GUICtrlCreateEdit("", 8, 104+15, 393, $mainGuiH/2-30, BitOR($ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM)
GUICtrlSetData(-1, "Edit2")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

Any help is appreciated. ;)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $mainGuiW = 410, $mainGuiH = 202
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", $mainGuiW, $mainGuiH, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Edit1 = GUICtrlCreateEdit("", 8, 8+30, 393, $mainGuiH/2-30, BitOR($ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "Edit1")
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP)
$Edit2 = GUICtrlCreateEdit("", 8, 104+15, 393, $mainGuiH/2-30, BitOR($ES_READONLY,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetResizing(-1, $GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKBOTTOM)
GUICtrlSetData(-1, "Edit2")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_SIZING, "WM_SIZING")


While 1
Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        GUIRegisterMsg($WM_SIZING, "")
        GUIDelete()
        Exit
    Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESTORE
        ResizeCtrl()
EndSwitch
WEnd

Func ResizeCtrl()
    Local $aPosCtrl = ControlGetPos($Form3, "", $Edit1)
    Local $aPosWin = WinGetPos($Form3)
    Local Const $iConst = 50 ;8 + 30 + 12
    Local $ypos = $aPosCtrl[3] + $iConst
    GUICtrlSetPos($Edit2, 8,  $ypos, $aPosCtrl[2], $aPosWin[3] - $ypos - $iConst)
EndFunc

Func WM_SIZING($hWnd, $Msg, $wParam, $lParam)
    ResizeCtrl()
    Return $GUI_RUNDEFMSG
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Awesome. The snapping window to the top (maximize) didn't work n I added $GUI_EVENT_RESTORE to Case $GUI_EVENT_MAXIMIZE, $GUI_EVENT_RESIZED and that part works. But if you drag the maximized window to centre of the screen (to restore it) it still won't work. I couldn't find any GUI_EVENT to fix that part.

Share this post


Link to post
Share on other sites

Change GUIRegisterMsg($WM_SIZE, "WM_SIZE") to GUIRegisterMsg($WM_SIZING, "WM_SIZING") and it should work.

I update the code.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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