Jump to content

Scrollbars Made Easy - New version 27 Jan 22


Melba23
 Share

Recommended Posts

Having seen the expertise of MVPs over here (which, of course, includes you), makes me suffer from inferiority complex. Only one word for you & your scrollbar control - mind blowing.

[size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size]

Link to comment
Share on other sites

  • Moderators

HolmesShelock,

makes me suffer from inferiority complex

Might I suggest using that feeling positively to spur you on to become a better AutoIt coder? That is certainly what I (and I am sure many of the others here) did. :unsure:

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

 

Link to comment
Share on other sites

Might I suggest using that feeling positively to spur you on to become a better AutoIt coder? That is certainly what I (and I am sure many of the others here) did. :unsure:

Surely I'll try to learn more & more. Posted Image

[size="2"][font="arial, verdana, tahoma, sans-serif"]ProtectData - A Data Protection software for floppies[/font][/size] [size="2"][hr][/size][size="2"]Sessionchange - A Windows service capable of tracking session change events[/size][size="2"][b][/b][/size]

Link to comment
Share on other sites

  • 2 weeks later...

Nice post Melba :unsure:

but afther download this file and included it in mijn include folder i did get a error report..

not a real biggy but i think more poeple gonna have this....

thought u might wanna look at the zip file.. :

C:\Program Files\AutoIt3\Include\GUIScrollbars_Ex.au3(155,33) : WARNING: $WM_MOUSEHWHEEL: possibly used before declaration.

GUIRegisterMsg($WM_MOUSEHWHEEL,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Include\GUIScrollbars_Ex.au3(160,32) : WARNING: $WM_MOUSEWHEEL: possibly used before declaration.

GUIRegisterMsg($WM_MOUSEWHEEL,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\Include\GUIScrollbars_Ex.au3(155,33) : ERROR: $WM_MOUSEHWHEEL: undeclared global variable.

GUIRegisterMsg($WM_MOUSEHWHEEL,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\~\test3.au3 - 1 error(s), 2 warning(s)

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

Those constants are declared in WindowsConstants.au3 - if I redeclare them in the UDF we get a "previously declared as a 'Const'" error. I felt that most people who wanted to use scrollbars would also be using that #include file. :>

So just add #include <WindowsConstants.au3> to your script (as it is in the examples) and all will be well. :unsure:

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

 

Link to comment
Share on other sites

So just add #include <WindowsConstants.au3> to your script (as it is in the examples) and all will be well.

lol .... I started the example and it said it;)

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

#include "GUIScrollbars_Ex.au3"

Global $iMax_Vert, $iPage_Vert, $nRatio_Vert, $iMax_Horz, $iPage_Horz, $nRatio_Horz, $iH_Tight, $iV_Tight

; Create wrapper GUI
$hGUI = GUICreate("Scroll Bar Examples", 520, 675)
GUISetBkColor(0xC4C4C4, $hGUI)

$hCheckBox_V = GUICtrlCreateCheckBox("", 10, 10, 20, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateLabel("Vertical Scrollbar",  10, 35, 80, 40)

$hVert_Labels = GUICtrlCreateLabel("Panel Ht:",  90, 10, 100, 20)
GUICtrlCreateLabel("Scroll Ht:", 90, 35, 100, 20)
GUICtrlCreateLabel("Ratio:",  90, 60, 100, 20)

$hLabel_AH = GUICtrlCreateLabel("", 190, 10, 50, 20)
$hLabel_SH = GUICtrlCreateLabel("", 190, 35, 50, 20)
$hLabel_RH = GUICtrlCreateLabel("", 190, 60, 50, 20)

$hCheckBox_H = GUICtrlCreateCheckBox("", 260, 10, 20, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateLabel("Horizontal Scrollbar",  260, 35, 80, 40)

$hHorz_Labels = GUICtrlCreateLabel("Panel Width:",  340, 10, 100, 20)
GUICtrlCreateLabel("Scroll Width:", 340, 35, 100, 20)
GUICtrlCreateLabel("Ratio:",  340, 60, 100, 20)

$hLabel_AW = GUICtrlCreateLabel("", 440, 10, 50, 20)
$hLabel_SW = GUICtrlCreateLabel("", 440, 35, 50, 20)
$hLabel_RW = GUICtrlCreateLabel("", 440, 60, 50, 20)

For $i = $hCheckBox_V To $hLabel_RW
    GUICtrlSetFont($i, 12)
    GUICtrlSetResizing($i, $GUI_DOCKALL)
Next

$hCheck_Tight = GUICtrlCreateCheckbox(" Tight", 100, 640, 80, 30)
GUICtrlSetFont(-1, 12)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
GUIStartGroup()
$hRadio_Before = GUICtrlCreateRadio(" Before", 280, 640, 80, 30)
GUICtrlSetFont(-1, 12)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
$hRadio_After = GUICtrlCreateRadio(" After", 380, 640, 80, 30)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 12)
GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM)
GUIStartGroup()

GUISetState()

; Start example
While 1

    If GUICtrlRead($hCheckBox_V) = 1 Then
        For $i = $hVert_Labels To $hLabel_RH
            GUICtrlSetState($i, $GUI_SHOW)
        Next
        $iAperture_Ht = Random(200, 500, 1)
        GUICtrlSetData($hLabel_AH, $iAperture_Ht)
        ; Random ratio for vertical scroll size
        $nRatio_Vert = Random(2, 20)
        GUICtrlSetData($hLabel_RH, Round($nRatio_Vert, 2))
        $iScroll_Ht = Int($iAperture_Ht * $nRatio_Vert)
        GUICtrlSetData($hLabel_SH, $iScroll_Ht)
    Else
        For $i = $hVert_Labels To $hLabel_RH
            GUICtrlSetState($i, $GUI_HIDE)
        Next
        $iAperture_Ht = 500
        $iScroll_Ht = 0
    EndIf

    If GUICtrlRead($hCheckBox_H) = 1 Then
        For $i = $hHorz_Labels To $hLabel_RW
            GUICtrlSetState($i, $GUI_SHOW)
        Next
        $iAperture_Width = Random(200, 500, 1)
        GUICtrlSetData($hLabel_AW, $iAperture_Width)
        ; Random ratio for horizontal scroll size
        $nRatio_Horz = Random(2, 20)
        GUICtrlSetData($hLabel_RW, Round($nRatio_Horz, 2))
        $iScroll_Width = Int($iAperture_Width * $nRatio_Horz)
        GUICtrlSetData($hLabel_SW, $iScroll_Width)
    Else
        For $i = $hHorz_Labels To $hLabel_RW
            GUICtrlSetState($i, $GUI_HIDE)
        Next
        $iAperture_Width = 500
        $iScroll_Width = 0
    EndIf

    If GUICtrlRead($hCheck_Tight) = 1 Then
        $iH_Tight = 1
        $iV_Tight = 1
    Else
        $iH_Tight = 0
        $iV_Tight = 0
    EndIf

    ; Resize wrapper GUI
    WinMove($hGUI, "", Default, Default, Default, $iAperture_Ht + 170)

    ; Create aperture GUI
    $hAperture = GUICreate("", $iAperture_Width, $iAperture_Ht, (520 - $iAperture_Width) / 2, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)

    ; If scrollbars to be created BEFORE controls
    If GUICtrlRead($hRadio_Before) = 1 Then
        ; Generate scrollbars
        $aAperture = _GUIScrollbars_Generate($hAperture, $iScroll_Width, $iScroll_Ht, $iH_Tight, $iV_Tight, True)
        If @error Then
            MsgBox(16, "Error", "Scrollbar generation failed")
            Exit
        EndIf
        ; Reset aperture size to smaller area with scrollbars in place
        $iAperture_Width = $aAperture[0]
        $iAperture_Ht = $aAperture[1]
    EndIf

    ; Create button to start scrolling
    $hButton_1 = GUICtrlCreateButton("Scroll", ($iAperture_Width - 80) / 2, 20, 80, 30)

    ; Create label to show edge if Tight selected
    If GUICtrlRead($hCheck_Tight) = 1 Then
        If GUICtrlRead($hCheckBox_V) = 1 Then
            $iY = $iScroll_Ht - 40
        Else
            $iY = $iAperture_Ht - 40
        EndIf
        If GUICtrlRead($hCheckBox_H) = 1 Then
            $iX = $iScroll_Width - 40
        Else
            $iX = ($iAperture_Width - 40) / 2
        EndIf
        $hCorner = GUICtrlCreateLabel("", $iX, $iY, 40, 40)
        GUICtrlSetBkColor(-1, 0xC4FFC4)
    EndIf

    ; Create max width and horizontal sizing labels if required
    If GUICtrlRead($hCheckBox_H) = 1 Then
        $iLine_Ht = $iAperture_Ht
        If GUICtrlRead($hCheckBox_V) = 1 Then $iLine_Ht = $iScroll_Ht
        GUICtrlCreateLabel("", $iScroll_Width - 3, 0, 3, $iLine_Ht - 3)
        GUICtrlSetBkColor(-1, 0xFF0000)
        For $i = 100 To 1500 Step 100
            GUICtrlCreateLabel($i, $i, 0, 30, 15)
            GUICtrlSetBkColor(-1, 0xC4FFC4)
        Next
        ; Create page size label
        $iLabel_Ht = 0
        If GUICtrlRead($hCheckBox_V) = 1 Then $iLabel_Ht = $iAperture_Ht
        GUICtrlCreateLabel("", $iAperture_Width - 50, $iLabel_Ht + 100, 100, 40)
        GUICtrlSetBkColor(-1, 0xC4C4FF)
        GUICtrlCreateLabel("Page 1", $iAperture_Width - 40, $iLabel_Ht + 115, 40, 15)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlCreateLabel("Page 2", $iAperture_Width + 5, $iLabel_Ht + 115, 40, 15)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    EndIf

    ; Create max length and vertical sizing labels if required
    If GUICtrlRead($hCheckBox_V) = 1 Then
        $iLine_Width = $iAperture_Width
        If GUICtrlRead($hCheckBox_H) = 1 Then $iLine_Width = $iScroll_Width
        GUICtrlCreateLabel("", 0, $iScroll_Ht - 3, $iLine_Width, 3)
        GUICtrlSetBkColor(-1, 0xFF0000)
        For $i = 100 To 5000 Step 100
            GUICtrlCreateLabel($i, 0, $i, 30, 15)
            GUICtrlSetBkColor(-1, 0xC4FFC4)
        Next
        ; Create page size label
        GUICtrlCreateLabel("", $iAperture_Width - 40, $iAperture_Ht - 50, 40, 100)
        GUICtrlSetBkColor(-1, 0xFFC4C4)
        GUICtrlCreateLabel("Page 1", $iAperture_Width - 40, $iAperture_Ht - 15, 40, 15)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
        GUICtrlCreateLabel("Page 2", $iAperture_Width - 40, $iAperture_Ht, 40, 15)
        GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    EndIf

    ; Get correction factors for subsequently created controls
    If GUICtrlRead($hRadio_After) = 1 Then
        $aFactor = _GUIScrollbars_Generate($hAperture, $iScroll_Width, $iScroll_Ht, $iH_Tight, $iV_Tight)
        If @error Then
            MsgBox(16, "Error", "Scrollbar generation failed")
            Exit
        EndIf
    EndIf

    GUISetState()

    ; Draw test label in bottom right corner
    If GUICtrlRead($hRadio_Before) = 1 Then
        ; Show alignment without factors with $fBefore
        GUICtrlCreateLabel("", $iScroll_Width - 10, $iScroll_Ht - 10, 10, 10)
        GUICtrlSetBkColor(-1, 0x0000FF)
    Else
        ; Show need for factors without $fBefore
        GUICtrlCreateLabel("", ($iScroll_Width - 10) * $aFactor[2], ($iScroll_Ht - 10) * $aFactor[3], 10 * $aFactor[2], 10 * $aFactor[3])
        GUICtrlSetBkColor(-1, 0x0000FF)
    EndIf

    While 1

        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $hButton_1

                ; Scroll page down if required
                If GUICtrlRead($hCheckBox_V) = 1 Then
                    _GUIScrollbars_Scroll_Page($hAperture, 0, 2)
                    Sleep(1000)
                EndIf
                If GUICtrlRead($hCheckBox_H) = 1 Then
                    ; Scroll page right if required
                    _GUIScrollbars_Scroll_Page($hAperture, 2)
                    Sleep(1000)
                EndIf

                ; Now scroll to extremity of scrollable GUI
                If GUICtrlRead($hCheckBox_H) = 1 Then _GUIScrollbars_Scroll_Page($hAperture, 99, 0)
                If GUICtrlRead($hCheckBox_V) = 1 Then _GUIScrollbars_Scroll_Page($hAperture, 0, 99)
                Sleep(1000)
                GUIDelete($hAperture)
                ExitLoop
            Case $hCheckBox_V, $hCheckBox_H, $hRadio_Before, $hRadio_After, $hCheck_Tight
                ; Delete current instance and start with new settings
                GUIDelete($hAperture)
                ExitLoop
        EndSwitch
    WEnd
WEnd

as finishing touch god created the dutch

Link to comment
Share on other sites

  • Moderators

FMS,

i needed to upgraid mine autoit version

It does help! :>

Glad you like the UDF. :unsure:

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

 

Link to comment
Share on other sites

  • 3 weeks later...

Got 2 questions:

1) can you make scrolling by just moving a mouse cursor (with shift pressed) or just keys like up/down/left/right

2) how can i get X,Y coords from scrolled area ? (under the mouse cursor)

screenshot avilable here http://zalil.ru/31163123

my script...

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "GUIScrollbars_Ex.au3"
#include <SendMessage.au3>
#include <array.au3>

;GUIRegisterMsg($WM_KEYUP, "WM_MOUSEWHEEL")

AutoItSetOption ( "MouseCoordMode", 0)
HotKeySet("{BACKSPACE}", "addsprite")

Global $WWW = 1024
Global $HHH = 768
Global $XX = 0
Global $YY = 0
Global $SPID = 0
Global $BRICKS = 0
Global $npos = 0
Global $nnpos = 0

$empty = "0x00"
$death = 0x21
$resp = 0x22
$redresp = 0x23
$bluresp = 0x24
$brick = 0x35

Dim $array[1]
Dim $arrayy[1]

#Region ### START Koda GUI section ### Form=Form1.kxf
$GUIX = GUICreate("TRX Designer v076", $WWW, $HHH, -3, 0,BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZE))
GUISetBkColor(0x444444)
$PANEL = GUICtrlCreateLabel(" ", 8, 8, 100, 225, $WS_BORDER)
GUICtrlSetBkColor(-1, 0x444444)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetState(-1,$GUI_DISABLE)
$COORDS = GUICtrlCreateLabel("X:0     Y:0", 16, 208, 83, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetColor(-1, 0xFFFF00)
$LOAD = GUICtrlCreateLabel("Load Map", 16, 32, 84, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetCursor (-1, 0)
$SAVE = GUICtrlCreateLabel("Save Map", 16, 55, 84, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetCursor (-1, 0)
$ADDSP = GUICtrlCreateLabel("Add Sprite", 16, 78, 84, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetColor(-1, 0xFFFF00)
GUICtrlSetCursor (-1, 0)
$IDSP = GUICtrlCreateLabel("SP ID: 000", 16, 184, 83, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetColor(-1, 0xFFFF00)
$BRK = GUICtrlCreateLabel("BRICKS: 0", 16, 160, 83, 17, BitOR($SS_CENTER,$SS_CENTERIMAGE))
GUICtrlSetColor(-1, 0xFFFF00)

$hGUI = GUICreate("", $WWW-117, $HHH-26, 117, 2, $WS_POPUP, $WS_EX_MDICHILD, $GUIX)
GUISetBkColor(0x000000)

_GUIScrollbars_Generate($hGUI, 8000, 4000,140,140)

GUISetState(@SW_SHOW,$GUIX)
GUISetState(@SW_SHOW,$hGUI)
#EndRegion ### END Koda GUI section ###










While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit


Case $ADDSP
ADDSPRITE()



Case $LOAD

FLUSH_ALL()

$mapa = FileOpenDialog("Choose Image","", "NFK Map (*.mapa)", 3)
WinSetTitle($GUIX, "", "TRX Designer - " & $mapa)

$zzz = FileOpen($mapa, 16)
$chars = FileRead($zzz,149)
$chars = StringRight($chars, 4)
$X = Dec(Stringleft($chars, 2))
$Y = Dec(Stringright($chars, 2))
$ww = $Y
$hh = $X
FileClose($zzz)


$filenew = FileOpen($mapa, 16) ; Открываем в режиме бинари чтения
FileRead($filenew,154) ; Отбрасываем шапку

; Построение мапки...

For $x = 0 to $ww-1 Step 1
For $i = 0 to $hh-1 Step 1

$xmapa = FileRead($filenew,1)
if $xmapa <> $EMPTY then



if $xmapa > $brick then
_ArrayAdd($array, GUICtrlCreatePic(@ScriptDir & "\Bricks\brick.bmp", $i*32, $x*16, 32, 16))
$array[0] = $array[0] + 1
$BRICKS = $BRICKS + 1
GUICtrlSetData($BRK,"BRICKS: "&$BRICKS)
endif


if $xmapa = $resp  then
_ArrayAdd($array, GUICtrlCreatePic(@ScriptDir & "\Bricks\resp.bmp", $i*32, $x*16, 32, 16))
$array[0] = $array[0] + 1
$BRICKS = $BRICKS + 1
GUICtrlSetData($BRK,"BRICKS: "&$BRICKS)
endif


endif

;if $xmapa <> $EMPTY then MsgBox(0,"xxx",$xmapa)


Next
Next
; Конец постоения мапки...

FileClose($filenew)
;GUICtrlSetState($Label1, $GUI_DISABLE)











EndSwitch
; Получаем координаты мышки
$pos = MouseGetPos()
if ($pos[0] <> $npos) or ($pos[1]<>$nnpos) Then
GUICtrlSetData($COORDS,"X:"&round($pos[0]/32)&"     "&"Y:"&round($pos[1]/16))
$npos = $pos[0]
$nnpos = $pos[1]
endif
; Конец
WEnd
Exit














Func ADDSPRITE()
$sprite = FileOpenDialog("Choose Image","", "Sprite (*.bmp)", 3)
$a = $npos
$b = $nnpos
_ArrayAdd($arrayy, GUICtrlCreatePic($sprite, $a, $b,0,0))
GUICtrlSetState(-1,$GUI_SHOW)
$arrayy[0] = $arrayy[0] + 1
;GUICtrlSetState($arrayy[0],$GUI_SHOW)
EndFunc



Func FLUSH_ALL()

$array_id = 1
while ($array[0] > 0)
GuiCtrlDelete($array[$array_id])
_ArrayDelete($array, $array_id)
$array[0] = $array[0] - 1
wend


$arrayy_id = 1
while ($arrayy[0] > 0)
GuiCtrlDelete($arrayy[$arrayy_id])
_ArrayDelete($arrayy, $arrayy_id)
$arrayy[0] = $arrayy[0] - 1
wend

Global $XX = 0
Global $YY = 0
Global $SPID = 0
Global $BRICKS = 0

_GUIScrollbars_Scroll_Page($hGUI, 1,1)

EndFunc



Func WM_MOUSEWHEEL($hWnd, $nMsg, $wParam, $lParam)
    Local $nKeys = BitAnd($wParam, 0x0000FFFF)
    Local $nDistance = BitShift($wParam, 16)

    If $nDistance > 0 Then
        _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEUP, 0)
    Else
        _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEDOWN, 0)
    EndIf
EndFunc

I tryed to get coords by

AutoItSetOption ( "MouseCoordMode", 2) and MouseGetPos(), but this not working...

Edited by Enforcer
[RU] Zone
Link to comment
Share on other sites

  • 2 weeks later...
  • Moderators

Enforcer,

And I have 2 answers! :alien:

- 1. Look for the mouse moving when "Shift" is pressed and then send a suitable message to the scrollbars.

- 2. You need to work out how much the underlying GUI has been scrolled and then add the mouse coordinates based on the client area. Fortunately the UDF already holds the necessary values to do the calculations.

I hope this short example will show you how to amend your own script - I have used GUIRegisterMsg to look for the mouse moving: :huh2:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

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

Global $dll = DllOpen("user32.dll")
Global $iLast_X, $iLast_Y

; Create GUI
Global $hGUI = GUICreate("Mouse Pos:", 500, 500)

; Add some labels
For $i = 0 To 900 Step 100
    GUICtrlCreateLabel($i, $i, $i)
Next

GUISetState()

; Create the scrollbars
_GUIScrollbars_Generate($hGUI, 1000, 1000)

; Look for mouse movement
GUIRegisterMsg($WM_MOUSEMOVE, "_WM_MOUSEMOVE")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($dll)
            Exit
    EndSwitch

WEnd

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

    #forceref $iMsg, $wParam, $wParam

    Local $iDirn

    ; Change to client area coord mode
    Local $iOld_Opt = Opt("MouseCoordMode", 2)

    ; Get Horz scrollbar position
    Local $iH_Scroll_Unit = _GUIScrollBars_GetScrollPos($hGUI, $SB_HORZ)
    ; Determine pixels scrolled
    ; The UDF has a value for character width, so we can determine the x coord of the left edge of the visible client area
    Local $iH_Scroll_Pos = $iH_Scroll_Unit * $aSB_WindowInfo[0][2]
    ; Add the mouse coords within the client area
    Local $iH_MousePos = $iH_Scroll_Pos + MouseGetPos(0)
    ; We now need to adjust this value because of the shrinking effect of initally adding the scrollbars - read the tutorial in the first post
    ; However, the UDF again knows the value to use - and we round the result
    Local $iMouse_X = Round($iH_MousePos / $aSB_WindowInfoEx[0][2])

    ; Now do the same thing for the Vert scrollbar - except I have put it in one line
    Local $iMouse_Y = Round((_GUIScrollBars_GetScrollPos($hGUI, $SB_VERT) * $aSB_WindowInfo[0][3] + MouseGetPos(1)) / $aSB_WindowInfoEx[0][3])

    ; And set the new mouse coords in the GUI title
    WinSetTitle($hGUI, "", "Mouse Pos: " & $iMouse_X & " x " & $iMouse_Y)

    ; Finally, reset the original mouse mode
    Opt("MouseCoordMode", $iOld_Opt)

    ; If Shift pressed then we want to scroll
    If _IsPressed("10", $dll) Then

        ; Get current mouse coords
        Local $iCurr_X = BitAND($lParam, 0xFFFF)
        Local $iCurr_Y = BitShift($lParam, 16)

        ; If x coord has changed
        If $iCurr_X <> $iLast_X Then
            ; Determine the direction to move
            $iDirn = $SB_LINERIGHT
            If $iCurr_X < $iLast_X Then
                $iDirn = $SB_LINELEFT
            EndIf
            ; Scroll in correct direction
            _SendMessage($hWnd, $WM_HSCROLL, $iDirn)
            ; Store current position
            $iLast_X = $iCurr_X
        EndIf

        ; Do the same for the Y coord
        If $iCurr_Y <> $iLast_Y Then
            $iDirn = $SB_LINERIGHT
            If $iCurr_Y < $iLast_Y Then
                $iDirn = $SB_LINELEFT
            EndIf
            _SendMessage($hWnd, $WM_VSCROLL, $iDirn)
            $iLast_Y = $iCurr_Y
        EndIf

    EndIf

EndFunc

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

 

Link to comment
Share on other sites

  • 7 months later...
  • Moderators

[New Version] - 20 Jan 12

Added functions to restore scrollbar position after a minimize/restore cycle:

For GUIScrollbars_Ex there are 2 functions: _GUIScrollbars_Minimize and _GUIScrollbars_Restore - called on the relevant events occurring. This is needed because of the way the UDF deals with the scrollbars it generates.

For GUIScrollbars_Size there is a single function: _GUIScrollbars_Restore.

The second example for each UDF has been modified to use these new functions. Thanks to rover and czardas for developing the code. :)

New UDFs, examples and zip file 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

 

Link to comment
Share on other sites

  • Moderators

LaCastiglione,

Thank rover and czardas - all I did was incorporate their code. :)

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

 

Link to comment
Share on other sites

Thank you for easy using of wide window with help your UDF.

Script "Beyond 256" is showing unicode chars with code more than $CodeShift. It's good idea to shift area of view by $CodeShift.

#include <GUIConstantsEx.au3>
#include "StaticConstants.au3"
#include "GUIScrollbars_Ex.au3"
Global $nX = 32, $nY = 40, $nDX = 50, $nDY = 25
Global $CodeShift = 0x300
Global $hLabel[$nX+1][$nY+1]
$hGUI = GUICreate("Beyond 256", 500, 500)
GUISetBkColor(0xFFFFFF, $hGUI)
for $i = 1 to $nX
for $j = 1 to $nY
  $hLabel[$i][$j] = GUICtrlCreateLabel(ChrW($CodeShift+($j-1)*$nX+$i), ($i-1)*$nDX, ($j-1)*$nDY, 40, 20, BitOr($SS_CENTER,$SS_SUNKEN))
GUICtrlSetBkColor(-1, 0xFFFFAA)
GUICtrlSetColor(-1, 0x000088)
next
next
_GUIScrollbars_Generate($hGUI, $nX*$nDX, $nY*$nDY)
GUISetState()
While 1
  $Msg = GUIGetMsg()
  Switch $Msg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $GUI_EVENT_RESTORE
   _GUIScrollbars_Restore($hGUI)
  Case $GUI_EVENT_MINIMIZE
   _GUIScrollbars_Minimize($hGUI)
  Case Else
   for $i = 1 to $nX
    for $j = 1 to $nY
     if $Msg = $hLabel[$i][$j] then
      MsgBox(0,"","You click char: "& @CrLf & ChrW($CodeShift+($j-1)*$nX+$i) & @CrLf & 'Hex code = ' & '0x' & Hex($CodeShift+($j-1)*$nX+$i,4) )
      ExitLoop(2)
    endif
   next
   next
EndSwitch
WEnd

The point of world view

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Is there a way to remove or disable the scrollbar?

So that in the GUIScrollbars_Size_Example_2.au3 script the scrollbar would just disappear when we would have less than 6 labels. We only need the vscroll when a control really goes over the clientarea.

I skimmed the UDF and this thread but couldn't find information.

Edited by Hawk
Link to comment
Share on other sites

  • Moderators

Hawk,

You just need to check if the required scrollbar size is less than the height of the GUI:

Case $hButton
    Do
        $iCount = Number(InputBox("Resize scroll area", "Select number of labels to display (min 5)", "", "", 240, 130))
    Until $iCount > 4

    _Draw_labels($iCount)

    If ($iCount + 1) * 50 <= 300 Then
        _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, False)
    Else
        _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, True)
        $aRet = _GUIScrollbars_Size(0, ($iCount + 1) * 50, 300, 300)
        _GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, $aRet[2])
        _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $aRet[3])
    EndIf

All clear? :)

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

 

Link to comment
Share on other sites

Yes thanks, everything clear.

I was looking for something like _GUIScrollBars_HideScrollBar() >_> Didn't know about the third parameter.

Edit: What I want to do is dynamically change the number of controls as well as their position and readjust the scrollbar to the correct size. I noticed that when I use ControlMove() or GUICtrlSetPos(), that controls will be moved to the current visible coordinates, not to the absolute GUI's coordinates.

Example: A control is at 0,500. The Vscrollbar is moved down, so that the visible clientarea starts at 0,400. If I do GUICtrlSetPos($control, 0, 0), the control will actually be moved to 0,450 because it takes the currently visible clientarea.

Taking your GUIScrollbars_Size_Example_2.au3, it can be reproduced by scrolling down, then pressing ENTER to activate the button, instead of clicking. Everything afterwards will be funny :)

Edit3: _GUIScrollBars_SetScrollInfoPos($hGUI, $SB_VERT, 0) before any moving fixes it for me.

Edit2: Also it seems that in any purpose just using _GUIScrollBars_ShowScrollBar($hGUI, $SB_VERT, False) is not enough. The window can still be scrolled with the mousewheel even when the scrollbar is hidden. Setting it to size 1 or so should hopefully fix that.

Edit4:

_GUIScrollBars_SetScrollInfoPage($hGUI, $SB_VERT, 0)

_GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, 0)

along with hiding it works for me.

Edited by Hawk
Link to comment
Share on other sites

  • Moderators

Hawk,

Already solved here. But note that you need to use the GUIScrollbars_Ex UDF to create the scrollbars for this function work. :)

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

 

Link to comment
Share on other sites

  • 3 weeks later...

I was looking for something like _GUIScrollBars_HideScrollBar() >_> Didn't know about the third parameter.

I also need ways to hide Scrollbars

Link to comment
Share on other sites

  • Melba23 changed the title to Scrollbars Made Easy - New version 27 Jan 22

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