Jump to content

Recommended Posts

Posted

Thank You M23

I have a little script attached

is for a new project

Working keyboard keys : space , up arrrow , down arrow

and working mouse of course

the vertical scroll is OK

BUT , do not follow the focused controls when i use up/down arrows.

is possible to tell somehow to the vertical scroll to follow

the active control when i use the keyboard ?

oneLess

oneLess_GUI.rar

 
 

 

  • Moderators
Posted

oneLess,

You will have to do work out how many items are on each scroll page and then set the correct page for the selected item - something like this:

#include "GUIScrollbars_Ex.au3"
#include <Misc.au3>

Global $_n = 100
Global $_targets_array[$_n][2]
Global $_label_numar
Global $_item_curent = 0
Global $_item_parasit = 0
Global $_item_maxim = $_n
Global $_fer_targets

Global $iPageLimit, $iOffSet = 2 ; The first checkbox is 2 * 20 down the GUI <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

_targets()

Func _targets()

    Local $_ferG_stil = BitOR($WS_SYSMENU, $WS_BORDER, $WS_POPUPWINDOW) ; BitOR ( $WS_SYSMENU, $WS_POPUPWINDOW  )

    Local $_fer_parent = GUICreate ("Tools", 500, 600, 10, 10, $_ferG_stil)

    Local $_ferG_width = 300 ;3*$_butT_width + 4*20
    Local $_ferG_height = 500 ; $_ecart_checbox * (11) + 3*20 - 10 + $_butT_height ;300
    Local $_ferG_left = 10 ;$_w_left - $_ferT_width - 20 ; 10
    Local $_ferG_top = 10 ;$_w_top ; 10 + 40*1

    Local $_msg_targets
    Local $_i

    ; How many checkboxes on each page? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $iPageLimit = $_ferG_height / 20

    $_fer_targets = GUICreate ("Tools", $_ferG_width, $_ferG_height, $_ferG_left, $_ferG_top, $_ferG_stil, -1, $_fer_parent)

    For $_i = 1 To $_n
        $_targets_array[$_i - 1][1 - 1] = GUICtrlCreateCheckbox("", 20, 40 + $_i * 20, 12, 12);,  15 , 150 )
    Next
    For $_i = 1 To $_n
        $_targets_array[$_i - 1][2 - 1] = GUICtrlCreateLabel ("" & $_i, 20 + 12 + 5, 40 + $_i * 20, 120, 12)
    Next
    _GUIScrollbars_Generate($_fer_targets, 0, 20 + 25 + 20 + $_n * 20)

    GUISetState(@SW_SHOW)

    GUISwitch($_fer_parent)

    Local $_butG_exit = GUICtrlCreateButton ("Exit", 420, 20, 60, 25)

    $_label_numar = GUICtrlCreateLabel("i", 350, 20, 60, 12)

    GUISetState(@SW_SHOW)

    Local $hDLL = DllOpen("user32.dll")

    _set_i(1)

    While 1

        ; Sleep(20) ; Not needed when there is a GUIGetMsg in the loop <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        $_msg_targets = GUIGetMsg()

        Select
            Case _IsPressed("28", $hDLL) ; {DOWN}
                _set_i_plus_1()
                While 1
                    If _IsPressed("28", $hDLL) = 0 Then ExitLoop
                    Sleep(20)
                WEnd
                _Set_Scroll() ; Set correct scroll page <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

                Case _IsPressed("26", $hDLL) ; {UP}
                _set_i_minus_1()
                While 1
                    If _IsPressed("26", $hDLL) = 0 Then ExitLoop
                    Sleep(20)
                WEnd
                _Set_Scroll() ; Set correct scroll page <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            Case $_msg_targets >= $_targets_array[1 - 1][2 - 1] And $_msg_targets <= $_targets_array[$_n - 1][2 - 1]
                _set_i(_identify_pe_i($_msg_targets, $_n))
            Case $_msg_targets >= $_targets_array[1 - 1][1 - 1] And $_msg_targets <= $_targets_array[$_n - 1][1 - 1]
                _set_i(_identify_pe_i($_msg_targets, $_n))
            Case $_msg_targets = $GUI_EVENT_CLOSE
                ExitLoop
            Case $_msg_targets = $_butG_exit
                ExitLoop
        EndSelect
    WEnd

    DllClose($hDLL)

    GUIDelete($_fer_targets)

EndFunc   ;==>_targets

Func _Set_Scroll() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    ; Determine which page of the scrolled GUI should be shown
    Local $iPage = Int(($_item_curent + $iOffSet) / $iPageLimit) + 1
    ; And scroll to it
    _GUIScrollbars_Scroll_Page($_fer_targets, 0, $iPage)
EndFunc

Func _identify_pe_i($_mesaj, $_numar)

    Local $_j
    Local $_id = 0

    For $_j = 1 To $_numar
        If $_targets_array[$_j - 1][1 - 1] = $_mesaj Or $_targets_array[$_j - 1][2 - 1] = $_mesaj Then
            $_id = $_j
            Return $_id
            MsgBox(-1, "", $_j, 1)
        EndIf
    Next

    Return $_id

EndFunc   ;==>_identify_pe_i

Func _set_i($_numar)

    $_item_parasit = $_item_curent
    $_item_curent = $_numar

    If $_item_parasit <> $_item_curent Then
        GUICtrlSetBkColor ($_targets_array[$_item_curent - 1][2 - 1], 0xaaaa00)
        GUICtrlSetState ($_targets_array[$_item_curent - 1][1 - 1], $GUI_FOCUS)
    EndIf

    If $_item_parasit <> 0 Then
        If $_item_parasit <> $_item_curent Then
            GUICtrlSetBkColor ($_targets_array[$_item_parasit - 1][2 - 1], -1)
        EndIf
    EndIf

    GUICtrlSetData($_label_numar, $_numar)

EndFunc   ;==>_set_i

Func _set_i_minus_1()

    If $_item_curent = 1 Then
        _set_i($_item_maxim)
    Else
        _set_i($_item_curent - 1)
    EndIf

EndFunc   ;==>_set_i_minus_1

Func _set_i_plus_1()
    If $_item_curent = $_item_maxim Then
        _set_i(1)
    Else
        _set_i($_item_curent + 1)
    EndIf
EndFunc   ;==>_set_i_plus_1
Please ask if you have any questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 1 month later...
Posted

Thanks it looks good when I ran it.  How would one normally create a popup message box from the main GUI.  I'm somehow lost as to how to open a separate window from the Main Function.

  • Moderators
Posted

nassausky,

That is not a question for this UDF thread - please post your question in the General Help section of the forums. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 2 months later...
Posted

Very useful! But is it possible to use it for a programatically changed label that aligns the text to the right? Here's an example:

#Include <GUIConstants.Au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIScrollBars_Ex.au3>
#include <StringSize.au3>
Global $Display_String = 'TestTestTestTestTestTestTest'

$hGUI = GUICreate("Test", 300, 90)
$Button = GUICtrlCreateButton("Add Text", 10, 60, 280, 20)

GUISetState()

$Wrapper = GUICreate("Scroll", 280, 30, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$Display = GUICtrlCreateLabel($Display_String, 0, 0, 280, 40, $SS_RIGHT)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUISetState()


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

Func _Update_Display()
    $Display_String = $Display_String & "Test"
    GUICtrlSetData($Display, $Display_String)
    $Return = _StringSize($Display_String, 10, 400, 0, "Arial")
    If $Return[2] > 265 Then
        _GUIScrollbars_Generate($Wrapper, $Return[2], 0)
    EndIf
EndFunc

In this example, the label still scrolls to the right, even though the remaining text is on the left, and thus just revealing empty space.

Thank you very much

  • 5 months later...
Posted

I'm using the UDF inside a GUI that creates buttons dinamically, so I have a fixed size GUI and I need to resize the scrollbars. I'm doing it just generating a new one in the GUI everytime that a new line of buttons is created:

1.png

I'm creating the scrollbars inside a _Addlines() funtion:

Func _Addlines()

    GUISwitch($Guilineas)
    ;as there are some other GUI in the script I have to switch to the needed one


    Local $anchoactual = 0 ;just a variable to set the with of the elements
    $i = $i + 1 ; Count index variable up
    $k = $k + 1 ; Count array size up


    IF $k > 3 Then ;If there are more than 3 rows of buttons then
        GUICtrlDelete($scrolls) ;I delete the previous scrollbars
    Global $scrolls = _GUIScrollbars_Generate($Guilineas, 0, $k * 55);and I do create a new one with the new height
    Endif

    ;Then I redim the array size for the buttons
    ReDim $ilinea[$k]
    ReDim $iOperacion[$k]
    ReDim $iHorainicio[$k]
    ReDim $iHorafinal[$k]
    ReDim $idiffhoras[$k]
    ReDim $iHorasproducc[$k]
    ReDim $ioperario[$k]

    ;And I start to create the new row of buttons
    $ilinea[$i] = GUICtrlCreateButton($k, 4, 55 * $i, $anchuraelementos / 16.84, 50)
    GUICtrlSetFont(-1, 32 - $fontdpi - $valorfuenteres, 700, 1, $sFont, 5)
    
    ;etc...

I don't know If:

IF $k > 3 Then ;If there are more than 3 rows of buttons then
        GUICtrlDelete($scrolls) ;I delete the previous scrollbars
    Global $scrolls = _GUIScrollbars_Generate($Guilineas, 0, $k * 55);and I do create a new one with the new height
    Endif

Works any better than:

IF $k > 3 Then
    Global $scrolls = _GUIScrollbars_Generate($Guilineas, 0, $k * 55)
Endif

As the result seems to be the same.

 

Another question that I have is: as the scrollbars are not working with a touchscreen when you swipe inside the gui but they do when you swipe on the scrollbar thumb it works perfectly... is it possible to create your scrollbars with a custom width?:

2.png

 

Greets from Barcelona

  • Moderators
Posted

Qwerty212,

There is no requirement to delete the scrollbars - and using GUICtrlDelete is useless anyway as the _GUIScrollbars_Generate function does not return a ControlID but an array of interesting data, as explained in the header:

; Return values .: Success - Returns a 4-element array (see remarks for details):
;                            [0] = Actual aperture width ; [1] = Actual aperture height]
;                            [2] = Width correction factor ; [3] = Height correction factor]

And as you appear to want to adjust the size of the scrollbars to match the changing size of the scrolled area, you should really be using the GUIScrollbars_Size UDF, not GUIScrollbars_Ex. Look at the example script GUIScrollbars_Size_Example_2 (which is included in the zip file) to see how to do it - you will see that you never delete and recreate the scrollbars, just adjust their parameters so that they match the size of the area to be scrolled.

The width of the scrollbars is set by the system and you can change it via the _WinAPI_SystemParametersInfo function.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted (edited)

Qwerty212.

I have split off our discussion on gesture scrolling into a new thread as at present it has little to do with the UDF proper - see you there.

That worked - not!

Somehow the split thread screwed up the entire forum and Jon had to rebuild a number of the tables to fix it - and at the end of it all we lost some all of the split posts forever. So I will start a new thread in GH&S when I have got some new code for you to test and link to it here.

M23

Edited by Melba23
Increased the Pk of the loss

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

Qwerty212,

The new thread is here.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

virhonestum,

My most sincere apologies - I have only just noticed your post #145 from April. But better late than never - here is the answer to your question:

#Include <GUIConstants.Au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIScrollBars_Size.au3>
#include <StringSize.au3>

Global $Display_String = 'Test0Test1Test2Test3Test4Test5Test6'
$iCount = 6

$hGUI = GUICreate("Test", 300, 90)
$Button = GUICtrlCreateButton("Add Text", 10, 60, 280, 20)

GUISetState()

$Wrapper = GUICreate("Scroll", 280, 30, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
$Display = GUICtrlCreateLabel($Display_String, 0, 0, 280, 40, $SS_RIGHT)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
GUISetState()

; Create scrollbars and hide them
_GUIScrollBars_Init($Wrapper)
_GUIScrollBars_ShowScrollBar($Wrapper, $SB_VERT, False)
_GUIScrollBars_ShowScrollBar($Wrapper, $SB_HORZ, False)

GUIRegisterMsg($WM_HSCROLL, "_Scrollbars_WM_HSCROLL")

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

Func _Update_Display()
    ; Update counter for display purposes
    $iCount += 1
    ; Add to string
    $Display_String &= "Test" & $iCount
    ; Amend GUI title
    WinSetTitle($hGUI, "", "Test " & $iCount)
    ; Size new string
    $Return = _StringSize($Display_String, 10, 400, 0, "Arial")
    ; Resize label to hold string and display it
    ControlMove($Wrapper, "", $Display, 0, 0, $Return[2], 40)
    GUICtrlSetData($Display, $Display_String)
    ; If label now too wide for aperture
    If $Return[2] > 280 Then
        ; Show the scrollbar
        _GUIScrollBars_ShowScrollBar($Wrapper, $SB_HORZ, True)
        ; Size the scrollbars and set the values
        $aRet = _GUIScrollbars_Size($Return[2], 0, $Wrapper)
        _GUIScrollBars_SetScrollInfoPage($Wrapper, $SB_HORZ, $aRet[0])
        _GUIScrollBars_SetScrollInfoMax($Wrapper, $SB_HORZ, $aRet[1])
    EndIf
EndFunc

Func _Scrollbars_WM_HSCROLL($hWnd, $Msg, $wParam, $lParam)

    #forceref $Msg, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $iIndex = -1, $xChar, $xPos
    Local $Page, $Pos, $TrackPos

    For $x = 0 To UBound($__g_aSB_WindowInfo) - 1
        If $__g_aSB_WindowInfo[$x][0] = $hWnd Then
            $iIndex = $x
            $xChar = $__g_aSB_WindowInfo[$iIndex][2]
            ExitLoop
        EndIf
    Next
    If $iIndex = -1 Then Return 0

    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    $xPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $xPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    Switch $nScrollCode
        Case $SB_LINELEFT
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
        Case $SB_LINERIGHT
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
        Case $SB_PAGELEFT
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
        Case $SB_PAGERIGHT
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
        Case $SB_THUMBTRACK
            DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
    EndSwitch

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)

    $Pos = DllStructGetData($tSCROLLINFO, "nPos")
    If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindow($hWnd, $xChar * ($xPos - $Pos), 0)

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_Scrollbars_WM_HSCROLL

As you can see, you need to use the _Scrollbars_Size UDF to do this as you must amend the scrollbar data to match the new size rather than constantly recreating the scrollbars.

Again my apologies - I hope the wait was worth it!

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Hi there,

this is not question in general about the UDF, but I have a small issue. In the scrollable part of the GUI I am creating controls if a user is pressing a button. As the new controls are suppossed to placed under old once I am using the ControlGetPos command to get the position data of the last control.

However when the scrollbar is moved the position data from ControlGetPos tells me a different position for the control. With _GUIScrollBars_GetScrollInfoPos I get the information where the scrollbar is placed, but how many pixels are moved by it? Is this a windows metric value or do I need to calculate it by myself using _GUIScrollBars_GetScrollInfoMax etc.?

  • Moderators
Posted

HurleyShanabarger,

As you have discovered, creating new controls on a scrollable GUI is fraught with difficulty. I have 2 suggestions as to how you might proceed:

  1. Create all the controls as the script commences and then show them when required - that way you are sure they will be in the correct place.
  2. Scroll the bar to the top before using ControlGetPos so that the return reflects the true position - but I have found this less than reliable as Windows seems not to honour exact positions once scrollbars are involved.

If you are looking to open a separate set of controls when the user presses this button, perhaps my GUIExtender UDF might be of more use to you - you can make sections of the GUI extend/retract at will and so only display those controls you wish at a specific time. Look in my sig for the link.

If none of the above seems to fit the bill then please give some more details of what exactly you are trying to achieve and we can see if we can come up with another solution.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

Hi Melba,

creating the control is not that difficult to understand. I was doing the mistake of using _GUIScrollbars_Generate when I wanted to resize/expand the scrollbar area. If I use _GUIScrollBars_SetScrollInfoMax instead it works just fine.

Thanks for the input!

  • 4 months later...
Posted
On 10/1/2015 at 8:05 PM, Melba23 said:

 

Hi Melba23,

I'm having a little issue with this... if you edit GUIScrollbars_Size_Example_2.au3 and change the max array length from 100 to 1000 and then try and draw 999 it will only draw 647 times because it's ran out of drawable space (even though there is space avaliable below),

It ends up looking like: 

xOOXxZV.png

How can we fix that?

  • Moderators
Posted

Hyflex,

Nothing to do with my UDF - you are running up against one of the limits of AutoIt. When you define the location of a control you must define the x and y coordinates - these are limited to a 16-bit signed integer (32767 0x7FFF). So as soon as you hit that limit, you cannot draw any more controls - czardas ran into the same problem earlier in this thread:

https://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy-new-version-22-nov-14/?do=findComment&comment=864808

So sorry, but nothing I can do.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 5 months later...
Posted

Would it be possible to get a very simple example with a section of scroll able items (like GUIScrollbars_Size_Example_2) but only PART of the GUI scrolls? The only example I see with a scroll-able section inside a normal window is the GUIScrollbars_Ex_Example_1, but it was too complex for me to figure out what was going on.

All I need is a resize-able window, with a vertical-scrollable section on the left and a static section on the right. I know this udf should be able to do this but couldn't figure it out.

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

  • Moderators
Posted (edited)

corgano,

Quote

All I need is a resize-able window, with a vertical-scrollable section on the left and a static section on the right

Does the scrollable section on the left remain the same size or does it resize with the main GUI?

M23

Edit: How about this?

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

#include <GUIScrollbars_Ex.au3>

$hGUI = GUICreate("Test", 500, 500, Default, Default, $WS_SIZEBOX)

GUISetState()

GUIRegisterMsg($WM_EXITSIZEMOVE, "_WM_EXITSIZEMOVE")

$aSize = WinGetClientSize($hGUI)

$hScroll = GUICreate("", $aSize[0] / 2, $aSize[1], -5, -5, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)

GUICtrlCreateLabel("000", 0, 0, 100, 100)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("100", 0, 100, 100, 100)
GUICtrlSetBkColor(-1, 0xCCFFCC)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("200", 0, 200, 100, 100)
GUICtrlSetBkColor(-1, 0xCCCCFF)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("300", 0, 300, 100, 100)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("400", 0, 400, 100, 100)
GUICtrlSetBkColor(-1, 0xCCFFCC)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("500", 0, 500, 100, 100)
GUICtrlSetBkColor(-1, 0xCCCCFF)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("600", 0, 600, 100, 100)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("700", 0, 700, 100, 100)
GUICtrlSetBkColor(-1, 0xCCFFCC)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("800", 0, 800, 100, 100)
GUICtrlSetBkColor(-1, 0xCCCCFF)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("900", 0, 900, 100, 100)
GUICtrlSetBkColor(-1, 0xFFCCCC)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateLabel("1000", 0, 1000, 100, 100)
GUICtrlSetResizing(-1, $GUI_DOCKALL)

GUISetState()

$iMaxScroll = 750

_GUIScrollbars_Generate($hScroll, 0, $iMaxScroll)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _WM_EXITSIZEMOVE($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam, $lParam

    ; Get position of client area origin
    Local $tPoint = DllStructCreate("int X;int Y")
    DllStructSetData($tPoint, "X", 0)
    DllStructSetData($tPoint, "Y", 0)
    _WinAPI_ClientToScreen($hWnd, $tPoint)

    ; Check if handle matches
    If $hWnd = $hGUI Then
        ; Get final size of main GUI
        Local $aClientSize = WinGetClientSize($hWnd)
        ; Resize scroll GUI
        WinMove($hScroll, "", DllStructGetData($tPoint, "X") , DllStructGetData($tPoint, "Y") , $aClientSize[0] / 2, $aClientSize[1])
        ; Mobve scrollbar to top
        _GUIScrollBars_SetScrollInfoPos($hScroll, $SB_VERT, 0)
        ; Regenerate scrollbars
        _GUIScrollbars_Generate($hScroll, 0, $iMaxScroll)
    EndIf

EndFunc

 

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

[New Version] - 16 Feb 17

Changed: Scrollbar size now determined dynamically rather than previous fixed value..

New UDFs and examples in first post.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

aberration,

Delighted you find it useful.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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
  • Recently Browsing   0 members

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