Jump to content

Scroll vertically a dinamic Form


Recommended Posts

Hi guys! How are you? Hope fine :) I'm here for asking you how to create a form that change is size dinamically ( based on the last "row" it meets ). 
Practically, I have an Excel file from which I read some data, and, for each row read, I create 3 different control input... This seems to be done, but I can't see the last rows because the form doesn't scroll vertically... Even If I set this parameter when I create the form:

GUICreate("", 553, 240, 243, 162, BitOR($GUI_SS_DEFAULT_GUI,$WS_VSCROLL))

How can I solve this? 
Thanks everyone for the help :) 

 

Edited by FrancescoDiMuro
Forgot thanks! :D

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Moderators

What kind of control are you using on the GUI to display the data? If you're using a ListView, like this, it should automatically be set up to scroll:

#include <Excel.au3>
#include <GUIConstantsEx.au3>

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\vMotion.xlsx")
Local $oRange = _Excel_RangeRead($oWorkbook, Default, "L1:L150")

    $hGUI = GUICreate("Test", 300, 300)
    $sListView = GUICtrlCreateListView("Column L", 10, 10, 100, 250)
        For $element In $oRange
            GUICtrlCreateListViewItem($element, $sListView)
        Next

    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi buddy! I have 2 textual fields, each of them is a column retrieved from Excel. I use 2 input ( GUICtrlCreateInput ) with readonly property. I've never used ListView... I use checkboxes for let the user choose which data retrieved from Excel have to be written to another file... I'm here listening to you :) Thanks for the reply :)

 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Moderators

@FrancescoDiMuro how about posting your code so we can actually see what you're doing? Help us help you ;)

An input control is, by design, a single-line field for accepting data. If you want to import a list, take a look at GUICtrlCreateEdit, or GuiCtrlCreateListView as I did above.

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ExcelConstants.au3>
#include <MsgBoxConstants.au3>
#include <Excel.au3>

; Prova con Assign!

;Opt("GUIResizeMode", $GUI_DOCKAUTO+$GUI_DOCKHEIGHT)

#Region ### START Koda GUI section ### Form=c:\users\portatile-60\documents\documenti lavoro\autoit\hta_creator\hta_creator.kxf
$Form_HTA_Creator = GUICreate("HTA Creator", 553, 437, 243, 162, BitOR($GUI_SS_DEFAULT_GUI,$WS_VSCROLL)) ;437
$label_Tag = GUICtrlCreateLabel("Tag", 99, 40, 40, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$label_Descrizione = GUICtrlCreateLabel("Descrizione", 243, 40, 114, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$label_Indice = GUICtrlCreateLabel("Riga", 19, 40, 45, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
;~ $checkbox_Scrivi_Modello = GUICtrlCreateCheckbox("", 453, 71, 17, 25)
$label_Scrivi = GUICtrlCreateLabel("Scrivi", 433, 40, 57, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
$button_CaricaLista = GUICtrlCreateButton("Carica Lista", 0, 0, 81, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
$button_CreaHTA = GUICtrlCreateButton("Crea HTA", 80, 0, 81, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
;~ $input_Indice_Modello = GUICtrlCreateInput("", 19, 72, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER))
;~ GUICtrlSetLimit(-1, 5)
;~ $input_Tag_Modello = GUICtrlCreateInput("", 61, 72, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
;~ $input_DescrizioneModello = GUICtrlCreateInput("", 175, 72, 249, 21)
;~ GUICtrlSetLimit(-1, 40)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $sListaIO

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button_CaricaLista
            CaricaLista()
    EndSwitch
WEnd

Func SelezionaListaIO()
    $sListaIO = FileOpenDialog("Scegli Lista I/O...", @ScriptDir, "All files (*.*)") ; Da cambiare...
    If @error Then
        MsgBox($MB_ICONERROR, "Operazione annullata!", "Operazione annullata dall'utente." & @CRLF & "Errore: " & @error)
    Else
        Return $sListaIO
    EndIf
EndFunc

Func CaricaLista()
    SelezionaListaIO()
    Local $aCheckboxes_CHECKED[2]
    ; Create application object and open an example workbook
    Local $oExcel = _Excel_Open(False)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante la creazione dell'oggetto Excel." & @CRLF & "Errore = " & @error & ", Informazioni = " & @extended)
    Local $oWorkbook = _Excel_BookOpen($oExcel, $sListaIO, False)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante l'apertura della Cartella di Lavoro '" & @ScriptDir & $sListaIO & "'." & @CRLF & "Errore = " & @error & ", Informazioni = " & @extended)
        _Excel_Close($oExcel)
        Exit
    EndIf
    $oWorkbook.Sheets("WR-ANALOG").Activate
    Local $aResult = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:D"))
    Local $aColonnaTags, $aColonnaDescrizioni, $i, $iX_Indice = 19, $iX_Tag = 61, $iX_Descrizione = 175, $iY = 72, $iY_chechbox_Scrivi = 71
    For $i = 2 To Ubound($aResult) - 1
        If($aResult[$i][3] = "") Then
            ; Do Nothing
        Else
            GUICtrlCreateInput($i, $iX_Indice, $iY, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_NUMBER))
            GUICtrlSetLimit(-1, 5)
            GUICtrlCreateInput($aResult[$i][0], $iX_Tag, $iY, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
            GUICtrlCreateInput($aResult[$i][3], $iX_Descrizione, $iY, 249, 21)
            GUICtrlSetLimit(-1, 40)
            ReDim $aCheckboxes_CHECKED[UBound($aCheckboxes_CHECKED) + 1]
            $aCheckboxes_CHECKED[$i] = GUICtrlCreateCheckbox("", 453, $iY_chechbox_Scrivi, 17, 25)
            $iY+=20
            $iY_chechbox_Scrivi+=20
        EndIf
    Next
    _Excel_Close($oExcel)
EndFunc

I was trying to store the name of Checkbox, in order to make a control about which checkboxes are checked...
I need to see and interact with the GUI... The first 3 inputs are for see what I have to do... Thanks for your answer :) 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

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...