Jump to content

Buttons and Input bunching together when resizing


Recommended Posts

Hello, I'm not great at putting GUI's together and I need help with this problem. When I resize the GUI window the buttons and inputs all bunch together instead of staying apart like they should. If anyone helps me out thanks a lot! -Donald

Code:

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

$E_Browser = _IECreateEmbedded()
$Home = "www.Google.com"
$Main = "C:\Users\Owner\Pictures\Logitech Webcam\Picture 28.jpg"

$Window = GUICreate("Web Browser", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW)
GUISetState()
GUISetState(@SW_MAXIMIZE)

$Height_Width = WinGetPos($Window)

$Background = GUICtrlCreatePic($main, 0, 0, $Height_Width[2], $Height_Width[3])
GUICtrlSetState($Background, $GUI_DISABLE)

$Browser = GUICtrlCreateObj($E_Browser, 10, 40, $Height_Width[2] - 40, $Height_Width[3] - 100)
_IENavigate($E_Browser, $Home)
$I_URL = GUICtrlCreateInput($Home, 250, 10, 200, 20)
$B_Refresh = GUICtrlCreateButton("Refresh", 540, 10, 70, 20)
$B_Go = GUICtrlCreateButton("Go", 460, 10, 70, 20, $BS_DEFPUSHBUTTON)
$B_Forward = GUICtrlCreateButton("Forward", 170, 10, 70, 20)
$B_Back = GUICtrlCreateButton ("Back", 90, 10, 70, 20)
$B_Home = GUICtrlCreateButton ("Home", 10, 10, 70, 20)
$B_Background = GUICtrlCreateButton ("Background", 630, 10, 70, 20)
GUICtrlSetResizing($Browser, 1)
GUICtrlSetResizing($Background, 1)




While 1
    Sleep(10)
    
    HotKeySet("{F5}", "_Refresh")
    
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $GUI_EVENT_MAXIMIZE
        GUICtrlSetResizing($Browser, 1)
        GUICtrlSetResizing($Background, 1)
    Case $msg = $B_Go
        $URL = GUICtrlRead($I_URL)
        _IENavigate($E_Browser, $URL)
    Case $msg = $B_Home
        _IENavigate($E_Browser, $Home)
    Case $msg = $B_Refresh
        _IEAction($E_Browser, "Refresh")
    Case $msg = $B_Back
        _IEAction($E_Browser, "Back")
    Case $msg = $B_Forward
        _IEAction($E_Browser, "Forward")
    Case $msg = $B_Background
        $Picture = FileOpenDialog("Select a picture...", "C:\Users\Owner\Pictures\Logitech Webcam", "Images (*.jpg;*.bmp)", 1)
        If $Picture <> "" Then
            GUICtrlSetImage($Background, $picture)
        Else
        EndIf
    EndSelect
WEnd


Func _Refresh()
    _IEAction($E_Browser, "Refresh")
EndFunc
Link to comment
Share on other sites

Yo must use GUICtrlSetResizing for each Control. Here's a example using GuiCtrlSetResizing:

#cs ----------------------------------------------------------------------------

    AutoIt Version: 3.3.6.1
    Author:                        AutoBert:    http://www.autoit.de/index.php?page=Thread&postID=164679#post164679

    Skriptbeispiel für den Umgang mit _IECreateEmbedded, _IEErrorHandlerRegister, _IENavigate, _IEAction GuiCtrlCreateProgress, _IEPropertyGet
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister()

$oIE = _IECreateEmbedded()
$SinkObject = ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2") ; Ereignisse den UDFs zuweisen, beginnend mit IEEvent_
GUICreate("Embedded Web control Test", 640, 600, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$hInput = GUICtrlCreateInput("Hier URL eingeben: ", 10, 10, 500)
$hGo = GUICtrlCreateButton("&Go", 520, 10, 50)
$GUIActiveX = GUICtrlCreateObj($oIE, 0, 40, 640, 480)
;$GUIActiveX = GUICtrlCreateObj($oIE, 0, 40, 683, 480)  ;wenn der vertikale Skrollbalken nicht zu sehen sein soll
GUICtrlSetResizing($GUIActiveX, $GUI_DOCKAUTO)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 525, 100, 22)
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 525, 100, 22)
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 525, 100, 22)
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 525, 100, 22)
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)
$GUI_Button_Print = GUICtrlCreateButton("PRINT", 450, 525, 100, 22)
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)
$idProgress = GUICtrlCreateProgress(0, 555, 640, 18)
GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR)

GUISetState() ;Show GUI

_IENavigate($oIE, "http://www.autoit.de/index.php?page=Thread&postID=164679#post164679")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $hGo
            _IENavigate($oIE, GUICtrlRead($hInput))
        Case $msg = $GUI_Button_Home
            _IENavigate($oIE, "http://www.autoitscript.com")
        Case $msg = $GUI_Button_Back
            _IEAction($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction($oIE, "stop")
        Case $msg = $GUI_Button_Print
            _IEAction($oIE, "print")
    EndSelect
    $surl1 = _IEPropertyGet($oIE, "locationurl")
    $surl2 = GUICtrlRead($hInput)
    ;        ConsoleWrite($surl1 & " " & $surl2 & " " & GUICtrlRead($idProgress) & @CRLF)
    If $surl1 <> $surl2 And GUICtrlRead($idProgress) > 90 Then GUICtrlSetData($hInput, $surl1)
WEnd


$SinkObject = 0 ; IE Eventzuweisung aufheben
$oIE.Quit ; IE beenden
$oIE = 0
GUIDelete()
Exit

Func IEEvent_ProgressChange($Progress, $ProgressMax)
    $percent = Int(($Progress * 100) / $ProgressMax)
    If $percent >= 0 And $percent <= 100 Then GUICtrlSetData($idProgress, $percent)
EndFunc   ;==>IEEvent_ProgressChange

mfg autoBert

Edited by AutoBert
Link to comment
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
 Share

  • Recently Browsing   0 members

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