Jump to content
Belini

Redimensionar janela e controles dela.

Recommended Posts

Sempre que preciso fazer um programa funcionar em mais de uma resolução preciso redimensionar a janela, reposicionar os controles e alterar o tamanho das fontes prá cada resolução então pensei se não haveria uma forma que desse para redimensionar tudo sem precisar fazer uma gui para cada resolução tipo usando o WinMove consigo redimensionar a janela mas os controles ficam fora do lugar, teria como quando usar o WinMove os controles serem redimensionados na mesma proporção da janela?

Share this post


Link to post
Share on other sites

Belini para fazer o que vc quer é facil.. basta posicionar os controles com posições baseadas em calculos.. vou postar um ex: bem básico.

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

Global $xs = 600, $ys = 500 ; Ajuste o tamanho da GUI para testes

GUICreate("Exemplo", $xs, $ys, -1, -1, $WS_SYSMENU)
GUICtrlCreateCombo("", 10, 10, 100, 20)
GUICtrlCreateCombo("", 10, 40, 100, 20)
GUICtrlCreateCombo("", 10, 70, 100, 20)


; estes controles sempre vai acompanhar o final da GUI
;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GUICtrlCreateLabel("Controle", $xs-140, $ys-90, 120, 20)
GUICtrlSetFont(-1, 14, 500, 0, "", 5)
GUICtrlCreateButton("Botão 1", $xs-180, $ys-60, 80, 20)
GUICtrlCreateButton("Botão 2", $xs-80, $ys-60, 50, 20)
;~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd
GUIDelete()

Share this post


Link to post
Share on other sites

Sempre que preciso fazer um programa funcionar em mais de uma resolução preciso redimensionar a janela, reposicionar os controles e alterar o tamanho das fontes prá cada resolução então pensei se não haveria uma forma que desse para redimensionar tudo sem precisar fazer uma gui para cada resolução tipo usando o WinMove consigo redimensionar a janela mas os controles ficam fora do lugar, teria como quando usar o WinMove os controles serem redimensionados na mesma proporção da janela?

 

Como sempre está corrido ai pra você né ? ... Pois já tem ai no Help, mas ...

 

... você pode fazer com o multeey falou , ou simplesmente usar oque já tem ai apertando F1 no SciTE. :muttley:

 

GUICtrlSetResizing :up:

 

Fui que estou no trabalho... :lol:

Share this post


Link to post
Share on other sites

@mutleey não quero que fique sempre na mesma posição e sempre com o mesmo tamanho e sim que sejam redimensionados e reposicionados de acordo com o tamanho da janela como se fosse uma imagem .jpg por exemplo que altera tudo quando proporcionalmente quando a gente redimensiona a foto.

 

@Fábio Igames vou ver GUICtrlSetResizing prá ver se faz o que eu preciso!

Share this post


Link to post
Share on other sites

@mutleey não quero que fique sempre na mesma posição e sempre com o mesmo tamanho e sim que sejam redimensionados e reposicionados de acordo com o tamanho da janela como se fosse uma imagem .jpg por exemplo que altera tudo quando proporcionalmente quando a gente redimensiona a foto.

 

@Fábio Igames vou ver GUICtrlSetResizing prá ver se faz o que eu preciso!

 

Com certeza , faz, lógico que o bom é fazer uma coisa que faço bem aqui ===> TESTAR. :up:

Já até sei oque quer fazer e ... eu já fiz aqui , e funciona em todas as resoluções. :muttley:

:autoit: + :cmd: AutoIt + C++ é D+ :D ;)

Share this post


Link to post
Share on other sites

Olá, minha sugestão:

#CS
    @TODO
#CE

#Region GUICreateEx
#include-once
#include <GUIConstantsEx.au3>
#include <FontConstants.au3>
#include <StringConstants.au3>
#include <AutoItConstants.au3>
#include <File.au3>
#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <GuiTreeView.au3>
#include <ListViewConstants.au3>
#include <Timers.au3>
#include <TreeViewConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <AVIConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("WinWaitDelay", 0)

#Region O segredo esta aqui para redimensionar os controles proporcionalmente
Opt("GUICoordMode", 1)
Opt("GUIResizeMode", 1)
#EndRegion

Global Enum $__HANDLE = 0, $__PARENT
Global $g__aNODES[1][2] = [[0]]

; FONT
Global Enum $_fNAME, $_fSMALL, $_fMEDIUM, $_fLARGE
Global $_FONT[4]
#EndRegion GUICreateEx


#Region Exemplo

OnAutoItExitRegister("OnExit")

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)

Global $aGuiSize[2] = [400, 400]
Global $sGuiTitle = "GuiTitle"
Global $hGui

$hGui = GUICreateEx($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1, $WS_OVERLAPPEDWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

#Region MENU
Local $idMenu1 = GUICtrlCreateMenu("Menu &One")
Local $idMenu2 = GUICtrlCreateMenu("Menu &Two")
GUICtrlCreateMenu("Menu Th&ree")
GUICtrlCreateMenu("Menu &Four")
GUICtrlCreateMenuItem('SubMenu One &A', $idMenu1)
GUICtrlCreateMenuItem('SubMenu One &B', $idMenu1)
#EndRegion MENU

#Region CONTEXT MENU
Local $idContextMenu = GUICtrlCreateContextMenu()
GUICtrlCreateMenuItem("Context Menu", $idContextMenu)
GUICtrlCreateMenuItem("", $idContextMenu) ; Separator
GUICtrlCreateMenuItem("&Properties", $idContextMenu)
#EndRegion CONTEXT MENU

#Region PIC
GUICtrlCreatePic("logo4.gif", 0, 0, 169, 68)
GUICtrlSetTip(-1, '#Region PIC')
GUICtrlCreateLabel("Sample Pic", 75, 1, 53, 15)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
#EndRegion PIC

#Region AVI
GUICtrlCreateAvi("SampleAVI.avi", 0, 180, 10, 32, 32, $ACS_AUTOPLAY)
GUICtrlSetTip(-1, '#Region AVI') ; TODO
GUICtrlCreateLabel("Sample avi", 175, 50)
GUICtrlSetTip(-1, '#Region AVI - Label')
#EndRegion AVI

#Region TAB
GUICtrlCreateTab(240, 0, 150, 70)
GUICtrlCreateTabItem("One")
GUICtrlSetTip(-1, '#Region TAB1')
GUICtrlCreateLabel("Sample Tab with TabItems", 250, 40)
GUICtrlCreateTabItem("Two")
GUICtrlSetTip(-1, '#Region TAB2')
GUICtrlCreateTabItem("Three")
GUICtrlSetTip(-1, '#Region TAB3')
GUICtrlCreateTabItem("")
#EndRegion TAB

#Region COMBO
GUICtrlCreateCombo("Sample Combo", 250, 80, 120, 100)
GUICtrlSetTip(-1, '#Region COMBO')
#EndRegion COMBO

#Region PROGRESS
GUICtrlCreateProgress(60, 80, 150, 20)
GUICtrlSetTip(-1, '#Region PROGRES')
GUICtrlSetData(-1, 60)
GUICtrlCreateLabel("Progress:", 5, 82)
GUICtrlSetTip(-1, '#Region PROGRES - Label')
#EndRegion PROGRESS

#Region EDIT
GUICtrlCreateEdit(@CRLF & "  Sample Edit Control", 10, 110, 150, 70)
GUICtrlSetTip(-1, '#Region EDIT')
#EndRegion EDIT

#Region LIST
GUICtrlCreateList("", 5, 190, 100, 90)
GUICtrlSetTip(-1, '#Region LIST')
GUICtrlSetData(-1, "A.Sample|B.List|C.Control|D.Here", "B.List")
#EndRegion LIST

#Region ICON
GUICtrlCreateIcon("explorer.exe", 0, 175, 120)
GUICtrlSetTip(-1, '#Region ICON')
GUICtrlCreateLabel("Icon", 180, 160, 50, 20)
GUICtrlSetTip(-1, '#Region ICON - Label')
#EndRegion ICON

#Region LIST VIEW
Global $idListView = GUICtrlCreateListView("Sample|ListView|", 110, 190, 110, 80, $LVS_NOCOLUMNHEADER)
GUICtrlSetTip(-1, '#Region LIST VIEW')
GUICtrlCreateListViewItem("key|value", $idListView)
GUICtrlCreateListViewItem("1|um", $idListView)
GUICtrlCreateListViewItem("2|dois", $idListView)
#EndRegion LIST VIEW

#Region GROUP WITH RADIO BUTTONS
GUICtrlCreateGroup("Sample Group", 230, 120)
GUICtrlCreateRadio("Radio One", 250, 140, 80)
GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO1')
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateRadio("Radio Two", 250, 165, 80)
GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO2')
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
#EndRegion GROUP WITH RADIO BUTTONS

#Region UPDOWN
GUICtrlCreateLabel("UpDown", 350, 115)
GUICtrlSetTip(-1, '#Region UPDOWN - Label')
GUICtrlCreateInput("42", 350, 130, 40, 20)
GUICtrlSetTip(-1, '#Region UPDOWN - Input')
GUICtrlCreateUpdown(-1)
GUICtrlSetTip(-1, '#Region UPDOWN - Updown')
#EndRegion UPDOWN

#Region LABEL
GUICtrlCreateLabel("Green" & @CRLF & "Label", 350, 165, 40, 40)
GUICtrlSetTip(-1, '#Region LABEL')
GUICtrlSetBkColor(-1, 0x00FF00)
#EndRegion LABEL

#Region SLIDER
GUICtrlCreateLabel("Slider:", 235, 215)
GUICtrlSetTip(-1, '#Region SLIDER - Label')
GUICtrlCreateSlider(270, 210, 120, 30)
GUICtrlSetTip(-1, '#Region SLIDER')
GUICtrlSetData(-1, 30)
#EndRegion SLIDER

#Region INPUT
GUICtrlCreateInput("Sample Input Box", 235, 255, 130, 20)
GUICtrlSetTip(-1, '#Region INPUT')
#EndRegion INPUT

#Region DATE
GUICtrlCreateDate("", 5, 280, 200, 20)
GUICtrlSetTip(-1, '#Region DATE')
GUICtrlCreateLabel("(Date control expands into a calendar)", 10, 305, 200, 20)
GUICtrlSetTip(-1, '#Region DATE - Label')
#EndRegion DATE

#Region BUTTON
GUICtrlCreateButton("Sample Button", 10, 330, 100, 30)
GUICtrlSetTip(-1, '#Region BUTTON')
#EndRegion BUTTON

#Region CHECKBOX
GUICtrlCreateCheckbox("Checkbox", 130, 335, 80, 20)
GUICtrlSetTip(-1, '#Region CHECKBOX')
GUICtrlSetState(-1, $GUI_CHECKED)
#EndRegion CHECKBOX

#Region TREEVIEW ONE
Local $idTreeView_1 = GUICtrlCreateTreeView(210, 290, 80, 80)
GUICtrlSetTip(-1, '#Region TREEVIEW ONE')
Local $idTreeItem = GUICtrlCreateTreeViewItem("TreeView", $idTreeView_1)
GUICtrlCreateTreeViewItem("Item1", $idTreeItem)
GUICtrlCreateTreeViewItem("Item2", $idTreeItem)
GUICtrlCreateTreeViewItem("Foo", -1)
GUICtrlSetState($idTreeItem, $GUI_EXPAND)
#EndRegion TREEVIEW ONE

#Region TREEVIEW TWO
Local $idTreeView_2 = GUICtrlCreateTreeView(295, 290, 103, 80, $TVS_CHECKBOXES)
GUICtrlSetTip(-1, '#Region TREEVIEW TWO')
GUICtrlCreateTreeViewItem("TreeView", $idTreeView_2)
GUICtrlCreateTreeViewItem("With", $idTreeView_2)
GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $idTreeView_2)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateTreeViewItem("Style", $idTreeView_2)
#EndRegion TREEVIEW TWO

_GUI_OnResize()

GUISetState(@SW_SHOW, $hGui)

While Sleep(25)
WEnd

#EndRegion Exemplo


#Region GUICreateEx
; #FUNCTION# ====================================================================================================================
; Version........:  0.0.0.2
; Name...........:  GUICreateEx
; Description ...:  Allow create a new GUI (Graphic User Interface) above current GUI and lock previus GUI
; Syntax.........:  same way of GuiCreate
; Parameters ....:  $sTitle.......: Title's GUI
;                   $iWidth.......: width's GUI
;                   $iHeight......: height's GUI
;                   $iLeft........: left position's GUI
;                   $iTop.........: top position's GUI
;                   $mStyle.......: Style's GUI
;                   $mExStyle.....: Extended Style's GUI
;                   $iParent......: The handle of another previously created window
; Return values .:  a windows handle
; Author ........:  Luismar Chechelaky
; Createdd.......:  2015/06/20 11:25
; Modified.......:  2017/07/28 12:00
; Remarks .......:
; Related .......:
; Link ..........:  https://github.com/chechelaky/AutoIt/raw/master/GuiCreateEx/GuiCreateEx.au3
; Example .......:

; 0.0.0.1 2015/06/20 11:25
;   Start development
; 0.0.0.2 2017/07/28 12:00
;   Refactor, remove unused resources
; ===============================================================================================================================
Func GUICreateEx($sTitle = "", $iWidth = 460, $iHeight = 360, $iLeft = -1, $iTop = -1, $mStyle = Default, $mExStyle = Default, $iParent = 0)
    Local $hWnd = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, $mStyle, $mExStyle, $iParent)
;~  GUISetOnEvent($GUI_EVENT_CLOSE, "_GUICreateEx_Quit", $hWnd)
    GUISetOnEvent($GUI_EVENT_CLOSE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_RESTORE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_MAXIMIZE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_RESIZED, "GuiEvents", $hWnd)

    If $iParent Then GUISetState(@SW_DISABLE, $iParent)
    GUISwitch($hWnd)
    _ArrayAdd2D($g__aNODES, $hWnd, $iParent, False)
    Return $hWnd
EndFunc   ;==>GUICreateEx

Func _GUICreateEx_Quit()
    Local $last = UBound($g__aNODES, 1) - 1
    GUISetState(@SW_HIDE, $g__aNODES[$last][$__HANDLE])
    GUIDelete($g__aNODES[$last][$__HANDLE])
    _ArrayDelete($g__aNODES, $last)

    $last = UBound($g__aNODES, 1) - 1
    If $last Then
        GUISwitch($g__aNODES[$last][$__HANDLE])
        GUISetState(@SW_ENABLE, $g__aNODES[$last][$__HANDLE])
        WinActivate($g__aNODES[$last][$__HANDLE])
    Else
        Exit
    EndIf
EndFunc   ;==>_GUICreateEx_Quit

Func GUICurrent()
    Return $g__aNODES[UBound($g__aNODES, 1) - 1][$__HANDLE]
EndFunc   ;==>GUICurrent

Func _GUI_OnResize()
    Local $dim = ControlGetPos(GUICurrent(), "", $idListView)
    If IsArray($dim) Then
        _GUICtrlListView_SetColumnWidth($idListView, 0, $dim[2] * 30 / 100 - 2)
        _GUICtrlListView_SetColumnWidth($idListView, 1, $dim[2] * 70 / 100 - 2)
    EndIf
EndFunc   ;==>_GUI_OnResize

Func SetFont($font, $small, $medium, $large)
    $_FONT[$_fNAME] = $font
    $_FONT[$_fSMALL] = $small
    $_FONT[$_fMEDIUM] = $medium
    $_FONT[$_fLARGE] = $large
EndFunc   ;==>SetFont
#EndRegion GUICreateEx

Func GuiEvents()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            _GUICreateEx_Quit()
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_MINIMIZE, GUICurrent())
        Case $GUI_EVENT_RESTORE
            GUISetState(@SW_RESTORE, GUICurrent())
            _GUI_OnResize()
        Case $GUI_EVENT_MAXIMIZE
            GUISetState(@SW_MAXIMIZE, GUICurrent())
            _GUI_OnResize()
        Case $GUI_EVENT_MOUSEMOVE
;~          ConsoleWrite("$GUI_EVENT_MOUSEMOVE" & @LF)
        Case $GUI_EVENT_PRIMARYDOWN
;~          ConsoleWrite("$GUI_EVENT_PRIMARYDOWN" & @LF)
        Case $GUI_EVENT_PRIMARYUP
;~          ConsoleWrite("$GUI_EVENT_PRIMARYUP" & @LF)
        Case $GUI_EVENT_SECONDARYDOWN
;~          ConsoleWrite("$GUI_EVENT_SECONDARYDOWN" & @LF)
        Case $GUI_EVENT_SECONDARYUP
;~          ConsoleWrite("$GUI_EVENT_SECONDARYUP" & @LF)
        Case $GUI_EVENT_RESIZED
;~          ConsoleWrite("$GUI_EVENT_RESIZED" & @LF)
            _GUI_OnResize()
        Case $GUI_EVENT_DROPPED
;~          ConsoleWrite("$GUI_EVENT_DROPPED" & @LF)
    EndSwitch
EndFunc   ;==>GuiEvents

Func OnExit()
    GUISetState($hGui, @SW_HIDE)
    GUIDelete($hGui)
EndFunc   ;==>OnExit

Func Quit()
    Exit
EndFunc   ;==>Quit

Func _ArrayAdd2D(ByRef $array, $m1 = Default, $m2 = Default, $m3 = Default, $m4 = Default, $m5 = Default, $m6 = Default, $m7 = Default, $m8 = Default, $m9 = Default, $m10 = Default, $m11 = Default, $m12 = Default, $m13 = Default, $m14 = Default)
    $array[0][0] = UBound($array, 1)
    ReDim $array[$array[0][0] + 1][UBound($array, 2)]
    Local $iCol = @NumParams - 1 < UBound($array, 2) ? @NumParams - 1 : UBound($array, 2)
    For $ii = 1 To $iCol
        $array[$array[0][0]][$ii - 1] = Execute("$m" & $ii)
    Next
    Return $array[0][0]
EndFunc   ;==>_ArrayAdd2D
  • Like 1

Share this post


Link to post
Share on other sites

 

Olá, minha sugestão:

#CS
    @TODO
#CE

#Region GUICreateEx
#include-once
#include <GUIConstantsEx.au3>
#include <FontConstants.au3>
#include <StringConstants.au3>
#include <AutoItConstants.au3>
#include <File.au3>
#include <GuiComboBoxEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <GuiTreeView.au3>
#include <ListViewConstants.au3>
#include <Timers.au3>
#include <TreeViewConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <AVIConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("WinWaitDelay", 0)

#Region O segredo esta aqui para redimensionar os controles proporcionalmente
Opt("GUICoordMode", 1)
Opt("GUIResizeMode", 1)
#EndRegion

Global Enum $__HANDLE = 0, $__PARENT
Global $g__aNODES[1][2] = [[0]]

; FONT
Global Enum $_fNAME, $_fSMALL, $_fMEDIUM, $_fLARGE
Global $_FONT[4]
#EndRegion GUICreateEx


#Region Exemplo

OnAutoItExitRegister("OnExit")

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)

Global $aGuiSize[2] = [400, 400]
Global $sGuiTitle = "GuiTitle"
Global $hGui

$hGui = GUICreateEx($sGuiTitle, $aGuiSize[0], $aGuiSize[1], -1, -1, $WS_OVERLAPPEDWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

#Region MENU
Local $idMenu1 = GUICtrlCreateMenu("Menu &One")
Local $idMenu2 = GUICtrlCreateMenu("Menu &Two")
GUICtrlCreateMenu("Menu Th&ree")
GUICtrlCreateMenu("Menu &Four")
GUICtrlCreateMenuItem('SubMenu One &A', $idMenu1)
GUICtrlCreateMenuItem('SubMenu One &B', $idMenu1)
#EndRegion MENU

#Region CONTEXT MENU
Local $idContextMenu = GUICtrlCreateContextMenu()
GUICtrlCreateMenuItem("Context Menu", $idContextMenu)
GUICtrlCreateMenuItem("", $idContextMenu) ; Separator
GUICtrlCreateMenuItem("&Properties", $idContextMenu)
#EndRegion CONTEXT MENU

#Region PIC
GUICtrlCreatePic("logo4.gif", 0, 0, 169, 68)
GUICtrlSetTip(-1, '#Region PIC')
GUICtrlCreateLabel("Sample Pic", 75, 1, 53, 15)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)
#EndRegion PIC

#Region AVI
GUICtrlCreateAvi("SampleAVI.avi", 0, 180, 10, 32, 32, $ACS_AUTOPLAY)
GUICtrlSetTip(-1, '#Region AVI') ; TODO
GUICtrlCreateLabel("Sample avi", 175, 50)
GUICtrlSetTip(-1, '#Region AVI - Label')
#EndRegion AVI

#Region TAB
GUICtrlCreateTab(240, 0, 150, 70)
GUICtrlCreateTabItem("One")
GUICtrlSetTip(-1, '#Region TAB1')
GUICtrlCreateLabel("Sample Tab with TabItems", 250, 40)
GUICtrlCreateTabItem("Two")
GUICtrlSetTip(-1, '#Region TAB2')
GUICtrlCreateTabItem("Three")
GUICtrlSetTip(-1, '#Region TAB3')
GUICtrlCreateTabItem("")
#EndRegion TAB

#Region COMBO
GUICtrlCreateCombo("Sample Combo", 250, 80, 120, 100)
GUICtrlSetTip(-1, '#Region COMBO')
#EndRegion COMBO

#Region PROGRESS
GUICtrlCreateProgress(60, 80, 150, 20)
GUICtrlSetTip(-1, '#Region PROGRES')
GUICtrlSetData(-1, 60)
GUICtrlCreateLabel("Progress:", 5, 82)
GUICtrlSetTip(-1, '#Region PROGRES - Label')
#EndRegion PROGRESS

#Region EDIT
GUICtrlCreateEdit(@CRLF & "  Sample Edit Control", 10, 110, 150, 70)
GUICtrlSetTip(-1, '#Region EDIT')
#EndRegion EDIT

#Region LIST
GUICtrlCreateList("", 5, 190, 100, 90)
GUICtrlSetTip(-1, '#Region LIST')
GUICtrlSetData(-1, "A.Sample|B.List|C.Control|D.Here", "B.List")
#EndRegion LIST

#Region ICON
GUICtrlCreateIcon("explorer.exe", 0, 175, 120)
GUICtrlSetTip(-1, '#Region ICON')
GUICtrlCreateLabel("Icon", 180, 160, 50, 20)
GUICtrlSetTip(-1, '#Region ICON - Label')
#EndRegion ICON

#Region LIST VIEW
Global $idListView = GUICtrlCreateListView("Sample|ListView|", 110, 190, 110, 80, $LVS_NOCOLUMNHEADER)
GUICtrlSetTip(-1, '#Region LIST VIEW')
GUICtrlCreateListViewItem("key|value", $idListView)
GUICtrlCreateListViewItem("1|um", $idListView)
GUICtrlCreateListViewItem("2|dois", $idListView)
#EndRegion LIST VIEW

#Region GROUP WITH RADIO BUTTONS
GUICtrlCreateGroup("Sample Group", 230, 120)
GUICtrlCreateRadio("Radio One", 250, 140, 80)
GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO1')
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateRadio("Radio Two", 250, 165, 80)
GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO2')
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
#EndRegion GROUP WITH RADIO BUTTONS

#Region UPDOWN
GUICtrlCreateLabel("UpDown", 350, 115)
GUICtrlSetTip(-1, '#Region UPDOWN - Label')
GUICtrlCreateInput("42", 350, 130, 40, 20)
GUICtrlSetTip(-1, '#Region UPDOWN - Input')
GUICtrlCreateUpdown(-1)
GUICtrlSetTip(-1, '#Region UPDOWN - Updown')
#EndRegion UPDOWN

#Region LABEL
GUICtrlCreateLabel("Green" & @CRLF & "Label", 350, 165, 40, 40)
GUICtrlSetTip(-1, '#Region LABEL')
GUICtrlSetBkColor(-1, 0x00FF00)
#EndRegion LABEL

#Region SLIDER
GUICtrlCreateLabel("Slider:", 235, 215)
GUICtrlSetTip(-1, '#Region SLIDER - Label')
GUICtrlCreateSlider(270, 210, 120, 30)
GUICtrlSetTip(-1, '#Region SLIDER')
GUICtrlSetData(-1, 30)
#EndRegion SLIDER

#Region INPUT
GUICtrlCreateInput("Sample Input Box", 235, 255, 130, 20)
GUICtrlSetTip(-1, '#Region INPUT')
#EndRegion INPUT

#Region DATE
GUICtrlCreateDate("", 5, 280, 200, 20)
GUICtrlSetTip(-1, '#Region DATE')
GUICtrlCreateLabel("(Date control expands into a calendar)", 10, 305, 200, 20)
GUICtrlSetTip(-1, '#Region DATE - Label')
#EndRegion DATE

#Region BUTTON
GUICtrlCreateButton("Sample Button", 10, 330, 100, 30)
GUICtrlSetTip(-1, '#Region BUTTON')
#EndRegion BUTTON

#Region CHECKBOX
GUICtrlCreateCheckbox("Checkbox", 130, 335, 80, 20)
GUICtrlSetTip(-1, '#Region CHECKBOX')
GUICtrlSetState(-1, $GUI_CHECKED)
#EndRegion CHECKBOX

#Region TREEVIEW ONE
Local $idTreeView_1 = GUICtrlCreateTreeView(210, 290, 80, 80)
GUICtrlSetTip(-1, '#Region TREEVIEW ONE')
Local $idTreeItem = GUICtrlCreateTreeViewItem("TreeView", $idTreeView_1)
GUICtrlCreateTreeViewItem("Item1", $idTreeItem)
GUICtrlCreateTreeViewItem("Item2", $idTreeItem)
GUICtrlCreateTreeViewItem("Foo", -1)
GUICtrlSetState($idTreeItem, $GUI_EXPAND)
#EndRegion TREEVIEW ONE

#Region TREEVIEW TWO
Local $idTreeView_2 = GUICtrlCreateTreeView(295, 290, 103, 80, $TVS_CHECKBOXES)
GUICtrlSetTip(-1, '#Region TREEVIEW TWO')
GUICtrlCreateTreeViewItem("TreeView", $idTreeView_2)
GUICtrlCreateTreeViewItem("With", $idTreeView_2)
GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $idTreeView_2)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateTreeViewItem("Style", $idTreeView_2)
#EndRegion TREEVIEW TWO

_GUI_OnResize()

GUISetState(@SW_SHOW, $hGui)

While Sleep(25)
WEnd

#EndRegion Exemplo


#Region GUICreateEx
; #FUNCTION# ====================================================================================================================
; Version........:  0.0.0.2
; Name...........:  GUICreateEx
; Description ...:  Allow create a new GUI (Graphic User Interface) above current GUI and lock previus GUI
; Syntax.........:  same way of GuiCreate
; Parameters ....:  $sTitle.......: Title's GUI
;                   $iWidth.......: width's GUI
;                   $iHeight......: height's GUI
;                   $iLeft........: left position's GUI
;                   $iTop.........: top position's GUI
;                   $mStyle.......: Style's GUI
;                   $mExStyle.....: Extended Style's GUI
;                   $iParent......: The handle of another previously created window
; Return values .:  a windows handle
; Author ........:  Luismar Chechelaky
; Createdd.......:  2015/06/20 11:25
; Modified.......:  2017/07/28 12:00
; Remarks .......:
; Related .......:
; Link ..........:  https://github.com/chechelaky/AutoIt/raw/master/GuiCreateEx/GuiCreateEx.au3
; Example .......:

; 0.0.0.1 2015/06/20 11:25
;   Start development
; 0.0.0.2 2017/07/28 12:00
;   Refactor, remove unused resources
; ===============================================================================================================================
Func GUICreateEx($sTitle = "", $iWidth = 460, $iHeight = 360, $iLeft = -1, $iTop = -1, $mStyle = Default, $mExStyle = Default, $iParent = 0)
    Local $hWnd = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, $mStyle, $mExStyle, $iParent)
;~  GUISetOnEvent($GUI_EVENT_CLOSE, "_GUICreateEx_Quit", $hWnd)
    GUISetOnEvent($GUI_EVENT_CLOSE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_MINIMIZE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_RESTORE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_MAXIMIZE, "GuiEvents", $hWnd)
    GUISetOnEvent($GUI_EVENT_RESIZED, "GuiEvents", $hWnd)

    If $iParent Then GUISetState(@SW_DISABLE, $iParent)
    GUISwitch($hWnd)
    _ArrayAdd2D($g__aNODES, $hWnd, $iParent, False)
    Return $hWnd
EndFunc   ;==>GUICreateEx

Func _GUICreateEx_Quit()
    Local $last = UBound($g__aNODES, 1) - 1
    GUISetState(@SW_HIDE, $g__aNODES[$last][$__HANDLE])
    GUIDelete($g__aNODES[$last][$__HANDLE])
    _ArrayDelete($g__aNODES, $last)

    $last = UBound($g__aNODES, 1) - 1
    If $last Then
        GUISwitch($g__aNODES[$last][$__HANDLE])
        GUISetState(@SW_ENABLE, $g__aNODES[$last][$__HANDLE])
        WinActivate($g__aNODES[$last][$__HANDLE])
    Else
        Exit
    EndIf
EndFunc   ;==>_GUICreateEx_Quit

Func GUICurrent()
    Return $g__aNODES[UBound($g__aNODES, 1) - 1][$__HANDLE]
EndFunc   ;==>GUICurrent

Func _GUI_OnResize()
    Local $dim = ControlGetPos(GUICurrent(), "", $idListView)
    If IsArray($dim) Then
        _GUICtrlListView_SetColumnWidth($idListView, 0, $dim[2] * 30 / 100 - 2)
        _GUICtrlListView_SetColumnWidth($idListView, 1, $dim[2] * 70 / 100 - 2)
    EndIf
EndFunc   ;==>_GUI_OnResize

Func SetFont($font, $small, $medium, $large)
    $_FONT[$_fNAME] = $font
    $_FONT[$_fSMALL] = $small
    $_FONT[$_fMEDIUM] = $medium
    $_FONT[$_fLARGE] = $large
EndFunc   ;==>SetFont
#EndRegion GUICreateEx

Func GuiEvents()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            _GUICreateEx_Quit()
        Case $GUI_EVENT_MINIMIZE
            GUISetState(@SW_MINIMIZE, GUICurrent())
        Case $GUI_EVENT_RESTORE
            GUISetState(@SW_RESTORE, GUICurrent())
            _GUI_OnResize()
        Case $GUI_EVENT_MAXIMIZE
            GUISetState(@SW_MAXIMIZE, GUICurrent())
            _GUI_OnResize()
        Case $GUI_EVENT_MOUSEMOVE
;~          ConsoleWrite("$GUI_EVENT_MOUSEMOVE" & @LF)
        Case $GUI_EVENT_PRIMARYDOWN
;~          ConsoleWrite("$GUI_EVENT_PRIMARYDOWN" & @LF)
        Case $GUI_EVENT_PRIMARYUP
;~          ConsoleWrite("$GUI_EVENT_PRIMARYUP" & @LF)
        Case $GUI_EVENT_SECONDARYDOWN
;~          ConsoleWrite("$GUI_EVENT_SECONDARYDOWN" & @LF)
        Case $GUI_EVENT_SECONDARYUP
;~          ConsoleWrite("$GUI_EVENT_SECONDARYUP" & @LF)
        Case $GUI_EVENT_RESIZED
;~          ConsoleWrite("$GUI_EVENT_RESIZED" & @LF)
            _GUI_OnResize()
        Case $GUI_EVENT_DROPPED
;~          ConsoleWrite("$GUI_EVENT_DROPPED" & @LF)
    EndSwitch
EndFunc   ;==>GuiEvents

Func OnExit()
    GUISetState($hGui, @SW_HIDE)
    GUIDelete($hGui)
EndFunc   ;==>OnExit

Func Quit()
    Exit
EndFunc   ;==>Quit

Func _ArrayAdd2D(ByRef $array, $m1 = Default, $m2 = Default, $m3 = Default, $m4 = Default, $m5 = Default, $m6 = Default, $m7 = Default, $m8 = Default, $m9 = Default, $m10 = Default, $m11 = Default, $m12 = Default, $m13 = Default, $m14 = Default)
    $array[0][0] = UBound($array, 1)
    ReDim $array[$array[0][0] + 1][UBound($array, 2)]
    Local $iCol = @NumParams - 1 < UBound($array, 2) ? @NumParams - 1 : UBound($array, 2)
    For $ii = 1 To $iCol
        $array[$array[0][0]][$ii - 1] = Execute("$m" & $ii)
    Next
    Return $array[0][0]
EndFunc   ;==>_ArrayAdd2D

 

Luigi ,sabia que você ira vir com uma solução mais simples , praticamente é bem lógico , o Evento GUIResizeMode já usa também GUICtrlSetResizing , e junto com GUICoordMode que também já utiliza de uma outra função nativa GUICtrlSetPos... :lol:

Ou seja , já faz todo os cálculos em todos os controles para nós :like_icon: , poupando o tempo maravilhoso de pensar .

Mãos a obra Belini , manda vê nesse RPS ai. :oops: :muttley:

:P

Edited by Fábio iGames

Share this post


Link to post
Share on other sites

Acho que eu já disse em outros posts, a grande falta do AutoIt é não ter uma UDF (ou library, ou o nome que você quiser) que facilite a criação de GUI de forma mais inteligente, reaproveitando o código, minimizando o trabalho braçal que temos que fazer.

Como a @Carlinha Fujiwara disse outro dia no chat: "tudo no AutoIt é na mão" e é uma grande verdade.

Eu pelo menos, ainda não vi uma dessa função.

Tenho ensaios de uma UDF assim, mas ela é funcional para ListView e TreeView, falta todos os outros elementos: Button, Label, Combo, Radio, Slider, Input, Edit e mais o "trem da alegria" todo... E tenho andando tão desanimado ultimamente, que tá ficando...

 

A grande maioria dos participantes assíduos do fórum, tem necessidades de uma UDF dessas, tenho certeza de que ela seria uma das mais utilizadas, quem dirá do fórum americano então...

 

Mas vamos lá, cada um compartilha o que sabe e adiante.

 

OBS: ainda existe muitos segredos à serem desvendados em "AutoItSetOption".

Share this post


Link to post
Share on other sites

Voltando ao assunto o meu maior problema é deixar as fontes proporcionais a nova dimensão ou seja se aumentar o tamanho da gui aumentar também o tamanho da fonte no controle, manter os controles no mesmo lugar e redimensionar proporcional dá prá fazer até mesmo por cálculos mas a fonte acompanhar o redimensionamento é que está sendo o problema!

Share this post


Link to post
Share on other sites

Acabei resolvendo o problema simplesmente não criando a segunda gui pois prá ter o dual view basta a gui exceder o comprimento do desktop aí criei ela maior e coloquei os 2 videos na mesma gui, agora as mensagens estão aparecendo normalmente!

  • Like 1

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


×