Sign in to follow this  
Followers 0
czardas

Return ASCII art

15 posts in this topic

I wish to display guitar chords on a GUI, and the easiest way seems to be to write the data in the format shown below. This representation is easy enough to understand and each pattern can easily be copied and pasted into another edit control. The problem is that I wish to display the chords side by side. I can not highlight either chord without also highlighting an adjacent chord. I could use images to represent the chords, but I really want to keep things simple for now - at least until I have tested the back end of my program.

Displaying the chords in an edit box is easy, but selecting them causes problems. Does anyone have any suggestions?

$sPattern1 = "xo   o,|||•||,||•|•|"
$sPattern2 = " x   o,•|||•|,||••||"

xo   o         x   o
|||•||        •|||•|
||•|•|        ||••||
||||||        ||||||
||||||        ||||||

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What about a special chord font?

http://simplythebest.net/fonts/fonts/frets.html

http://www.fontspace.com/philippe-blondel/accords

Edit: You could also convert the chords to ASCII-art afterwards if you need them in that way.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

What about a special chord font?

http://simplythebest.net/fonts/fonts/frets.html

http://www.fontspace.com/philippe-blondel/accords

Thanks for the suggestion. There are many more patterns than are available in any font (about 3000+ I think). The shapes have been generated by an algorithm. I think I may have found a solution using listview with $LVS_SINGLESEL.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try selecting with alt held down. Didn't you already do something like that with that magic string editor?

Alternatively, avoid putting two ore more chords on the same line. Two solutions: Simply put newlines between each chord. Alternatively, create multiple edit views side by side. One for each control.

Another solution: Copy button under each chord. Why even select at all?

Edited by Manadar

Share this post


Link to post
Share on other sites

LOL, Yeah that Line Magic I made had a feature to do that, but I didin't like how it displayed the selection. Pressing Alt is a neat trick, but it doesn't quite seem to work. I also thought of using labels or buttons, but then I will have to create a scrolling GUI and calculate lots of button positions. If I could create something like a spreadsheet or table in a rich edit that would be a posssible solution. I could also use a html table, but that would involve too much messy code IMO.

Share this post


Link to post
Share on other sites

You can make a scrolling GUI very easily with _GUIScrollBars_EnableScrollBar. I think the calculations will not be so hard: I managed to do them when I was 15. :x Haha. Good luck.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can make a scrolling GUI very easily with _GUIScrollBars_EnableScrollBar. I think the calculations will not be so hard: I managed to do them when I was 15. :x Haha. Good luck.

Yeah the positioning isn't so hard. Although ListView seems ideal, but for some reason I'm struggling to get it to work. I don't know why there are two different ways to create a listview. If I use _GUICtrlListView_Create then I can't figure out how to set the font. If I use GUICtrlCreateListView I have trouble with $LVS_SINGLESEL. Maybe I just need to play around with it for a while. Otherwise I guess I'll have use labels or multiple edit boxes, but that's annoying. I was hoping someone might know a better solution than this.

This is the effect I want. I have butchered something in the help file, but I'm not sure if I'm doing the right thing. How to set the font to Lucida console?

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

Example_UDF_Created() ;use UDF built listview

Func Example_UDF_Created()
    Local $GUI, $hImage, $hListView
    Local $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)

    $GUI = GUICreate("(ListView Set ????", 600, 550)

    ;=========================================================================================================
    $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 596, 500, $LVS_SINGLESEL, -1, True) ; Last option Calls CoInitializeEx
    ;GUICtrlSetFont($hListView, 30, 500, -1, "Lucida Console")

    ; Add columns
    _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
    _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
    _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem($hListView, "xo   o:|||•||", 0)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
    _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
    _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
    _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

    GUISetState()

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    GUIDelete()

EndFunc   ;==>Example_UDF_Created
Edited by czardas

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Okay I have messed around with ListView for long enough now. I think I'll do what Manadar suggests. Thanks for the responces. :x

Edited by czardas

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This is the minimalist version of the one I use in my lessons shaped from Achilles thread. Maybe someone skilled can suit this to your purpose quicker than I.

-right click clears the list

-double left click shows that chord in the viewer

-single left click selects/unselects items for practice

Most of what I know of this I picked up from the practice guitar thread, but I get extra helpful when its something that may change up or enhance instruction.

#include <Array.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Math.au3>

Opt('GUIResizeMode', 802)
Global Const $WIDTH = 200, $HEIGHT = 300, $B = 10
Global Const $EXTRA_HEIGHT = 150
$n = 28
Global $chordData[$n][5] = [['A major', '1.2|1.3|1.4', 'xo|||o' , '_Amajor' , ''] , ['A major 7', '1.2|1.4', 'xo|o|o' , '_Amajor7', ''], _
['A suspend 2', '1.2|1.3', 'xo||oo' , '_Asus2', ''], ['A suspend 4', '1.2|1.3|2.4', 'xo|||o' , '_Asus4', ''], ['A minor', '1.2|1.3|0.4', 'xo|||o', '_Aminor', ''], _
['B flat minor', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|1.4', '||||||' , '_Bflatminor', '']  , ['B flat major', '0.0|0.1|0.2|0.3|0.4|0.5|2.2|2.3|2.4', '||||||' , '_Bflatmajor', ''], _
['B major', '1.0|1.1|1.2|1.3|1.4|1.5|3.2|3.3|3.4', '||||||' , '_Bmajor', ''] , ['B major 7', '1.1|0.2|1.3|1.5', 'x|||o|', '_Bmajor7', ''] , ['C major', '2.1|1.2|0.4', 'x||o|o' , '_Cmajor', ''], _
['C major 7', '2.1|1.2|2.3|0.4', 'x||||o' , '_Cmajor7', ''],  ['C minor', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|3.4', '||||||' , '_Cminor', ''], _
['D major', '1.3|2.4|1.5', 'xxo|||' , '_Dmajor', ''],  ['D major 7', '1.3|0.4|1.5', 'xxo|||' , '_Dmajor7', ''],  ['D minor', '1.3|2.4|0.5', 'xxo|||' , '_Dminor', ''], _
['D suspend 2', '1.3|2.4', 'xxo||o' , '_Dsus2', ''],  ['D suspend 4', '1.3|2.4|3.5', 'xxo|||', '_Dsus4', ''], ['E major', '1.1|1.2|0.3', 'o||||oo' , '_Emajor', ''], _
['E7', '1.1|0.3', 'o|o||oo' , '_Emajor7', ''], ['E minor', '1.1|1.2', 'o||ooo' , '_Eminor', ''], ['E suspend 4', '1.1|1.2|1.3', 'o|||oo' , '_Esus4', ''], _
['F major 7', '2.2|1.3|0.4', 'xx|||o' , '_Fmajor7', ''] ,  ['G major', '2.0|1.1|2.4|2.5', '||oo||' , '_Gmajor', ''], _
['G major Barre', '2.0|2.1|2.2|2.3|2.4|2.5|4.1|4.2|3.3', '||||||' , '_GmajorBarre', ''] , ['G minor Barre', '2.0|2.1|2.2|2.3|2.4|2.5|4.1|4.2', '||||||' , '_GminorBarre', ''] , _
['G major 7', '2.0|1.1|0.5', '||ooo|' , '_Gmajor7', ''],  ['D sharp minor', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|3.4', '||||||' , '_Dsharpminor', '4'], _
['D sharp major', '2.0|2.1|2.2|2.3|2.4|2.5|4.2|4.3|4.4', '||||||' , '_Dsharpmajor', '4']]



Global $listview = -1
Global $checkedList[UBound($chordData)]
For $i = 0 to UBound($chordData) - 1
    $checkedList[$i] = 1
Next
Global $currentIndex = -1
$gui = GUICreate('Chord Practice', $WIDTH + $B * 2, $HEIGHT + $B * 8)
$chordPic = '56]'
Global $xOffset = 5
$chordName = GUICtrlCreateLabel('', $B * 2, $B * 2.5, $WIDTH - $B * 2, 32, $SS_CENTER)
GUICtrlSetFont(-1, 20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 20, 500, -1, 'Tahoma')
Global $lblStrum[6]
For $i = 0 to UBound($lblStrum) - 1
$lblStrum[$i] = GUICtrlCreateLabel('', 31 - $xOffset + 30 * $i, 53, 20, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetFont(-1, 16, 500, -1, 'Tahoma')
Next
$txtInterval = GUICtrlCreateInput('2', $B, $HEIGHT + $B * 2, 40, 20, $ES_NUMBER)
GUICtrlCreateUpdown($txtInterval)
GUICtrlCreateLabel('Interval (seconds)', $B + 45, $HEIGHT + $B * 2 +3, 90)
$startStop = GUICtrlCreateButton('Start', $WIDTH - 40, $HEIGHT + $B * 2, 50, 20)
$btnExpand = GUICtrlCreateButton('>>>', $B, $HEIGHT + $B * 5, $WIDTH, 20)
$expanded = False
GUISetState()

Global $Object = ObjCreate("SAPI.SpVoice")




While 1
    GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    Case $startStop
        If GUICtrlRead($startStop) = 'Start' then
            $int = GUICtrlRead($txtInterval)
            If $int < 1 then
                $int = 1
                GUICtrlSetData($txtInterval, $int)
            EndIf
            AdlibRegister('_ChangeChordPic', $int * 2000)

            GUICtrlSetState($txtInterval, $GUI_DISABLE)
            GUICtrlSetState($btnExpand, $GUI_DISABLE)
            _UpdateCheckedList()


            $string = 0

            For $i = 0 To UBound($checkedlist) - 1
    $string += $checkedlist[$i]
Next



        If $string < 1 Then
GUIDelete ($gui)
msgbox (0, '', 'please open again and select 1 or more items')
exit
endif
            If $expanded then
                _Contract()
                EndIf
GUICtrlSetData($startStop, 'Stop')
                _ChangeChordPic()
                            Else
                AdlibUnRegister('_ChangeChordPic')
            GUICtrlSetData($startStop, 'Start')
            GUICtrlSetState($txtInterval, $GUI_ENABLE)
            GUICtrlSetState($btnExpand, $GUI_ENABLE)
     For $i = 0 to _GUICtrlListView_GetItemCount($listview) - 1
        $checkedList[$i] = 1
If $checkedList[$i] = 1 then
                _GUICtrlListView_SetItemChecked($listview, $i, True)
            EndIf
next

Endif
    Case $btnExpand
        If $expanded then
            _Contract()
        Else
            _Expand()
        EndIf
    EndSwitch
WEnd

Func _ChangeChordPic()
    Local $index = -1
    Do
        $index = Random(0, UBound($checkedlist) - 1, 1)
    Until $index - 1 <> $currentIndex and $checkedList[$index] = 1
    $currentIndex = $index
    _SetChord()
    $saychord = StringReplace ($chorddata[$index][0], "A" , "eigh" , 0 , 1)
    $saychord1 = StringReplace ($saychord, "flat" , "phlat")
    $Object.Speak($saychord1, 0)
    call ($chorddata[$index][3])
EndFunc

Func _UpdateCheckedList()
    For $i = 0 to _GUICtrlListView_GetItemCount($listview) - 1
        If _GUICtrlListView_GetItemChecked($listview, $i)  then
            $checkedList[$i] = 1
        Else
            $checkedList[$i] = 0
        EndIf
    Next
EndFunc

Func _Contract()
    GUICtrlSetState($listview, $GUI_HIDE)
    $pos = WinGetPos($gui)
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] - $EXTRA_HEIGHT)
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5, $WIDTH, 20)
    $expanded = False
    GUICtrlSetData($btnExpand, '>>>')
EndFunc

Func _Expand()
    msgbox (0, '' , 'you must select 1 or more items, otherwise program will exit')
    $pos = WinGetPos($gui)
    WinMove($gui, '', $pos[0], $pos[1], $pos[2], $pos[3] + $EXTRA_HEIGHT)
    If $listview <> -1 then
        GUICtrlSetState($listview, $GUI_SHOW)
    Else
        $listview = GUICtrlCreateListView('Chord', $B, $HEIGHT + $B * 5, $WIDTH, $EXTRA_HEIGHT)
        _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES ))   ;$LVS_EX_ONECLICKACTIVATE
        _GUICtrlListView_SetColumnWidth($listview, 0, $WIDTH - 30)
        For $i = 0 to UBound($chordData) - 1
            _GUICtrlListView_AddItem($listview, $chordData[$i][0])
            If $checkedList[$i] = 1 then
                _GUICtrlListView_SetItemChecked($listview, $i, True)
            EndIf
        Next
    EndIf
    GUICtrlSetPos($btnExpand, $B, $HEIGHT + $B * 5 + $EXTRA_HEIGHT + 5, $WIDTH, 20)
    $expanded = True
    GUICtrlSetData($btnExpand, '<<<')
    GUICtrlSetState(-1 , $GUI_ENABLE)
EndFunc

Func _SetChord()
    GUICtrlDelete($chordPic)
    $chordPic = GUICtrlCreateGraphic($B, $B, $WIDTH, $HEIGHT)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetData($chordName, $chordData[$currentIndex][0])
    $strum = StringSplit($chordData[$currentIndex][2], '')
    For $i = 0 to UBound($lblStrum) - 1
        If $strum[$i + 1] = '|' then $strum[$i + 1] = ''
            GUICtrlSetData($lblStrum[$i], $strum[$i + 1])
        Next
        For $i = 1 to 6
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, $i * 30 - $xOffset, 65, 2, 184)
        Next
        GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 65, 150, 2)
        For $i = 0 to 5
            GUICtrlSetGraphic($chordPic, $GUI_GR_RECT, 30 - $xOffset, 72 + $i * 35, 150, 2)
        Next
        $pos = StringSplit($chordData[$currentIndex][1], '|')
        GUICtrlSetGraphic($chordPic, $GUI_GR_COLOR, 0, 0)
        GUICtrlCreateLabel ( $chorddata[$currentindex][4], 20 - $xOffset, 88, 10, 13 )
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetFont (-1 , '' , 600)
        For $i = 0 to UBound($pos) - 2
            $stringSplit = StringSplit($pos[$i + 1], '.')
            GUICtrlSetGraphic($chordPic, $GUI_GR_ELLIPSE, ($stringSplit[2] + 1) * 30 - 15, ($stringSplit[1]) * 35 + 63 + 35/2, 22, 22)
        Next
        GUICtrlSetGraphic($chordPic, $GUI_GR_REFRESH)
    EndFunc

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $hWndListView = $listview
    If Not IsHWnd($listview) Then $hWndListView = GUICtrlGetHandle($listview)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
            Case $NM_DblClk
                $currentindex = -1
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                        $CurrentIndex =  _GUICtrlListView_GetHotItem ($hWndlistview)
                        If $CurrentIndex   = -1 Then
                        $CurrentIndex = 0
                    Else
                    If _GUICtrlListView_GetItemChecked($hWndlistview, $CurrentIndex) then
                        _GUICtrlListView_SetItemChecked($hWndlistview, $CurrentIndex, False)
                    Else
                        _GUICtrlListView_SetItemChecked($hWndlistview, $CurrentIndex)
                    endif
                EndIf
                _setchord()
                Case $NM_RCLICK

                For $i = 0 to _GUICtrlListView_GetItemCount($hWndlistview) - 1
            If $checkedList[$i] = 1 then
                _GUICtrlListView_SetItemChecked($listview, $i, False)

            EndIf
        Next

                    Case $NM_RDBLCLK

                        For $i = 0 to $n -1
                        If $checkedlist[$i] = 1 then
                _GUICtrlListView_SetItemChecked($listview, $i, True)
                Endif
            Next


            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

iamtheky

Thanks for the illustration. I haven't used GUICtrlSetGraphic before, so I'll have to experiment with it for a while. I like the way the chords look. I appreciate this. :x

I may use this method with a scrolling GUI.

Share this post


Link to post
Share on other sites

I have made a start with the scrolling GUI, but I'm a bit confused about setting the maximum scroll height. How is that measured. In the script below I have a strange formula which I found by trial and error, and it seems to work for up to about 4000 labels added. Although I won't need to adjust the max scroll distance so much, I could do with knowing the units of measurement. ATM I have: max scroll = 2.5 * the number of labels. Each label is 40 pixels but I'm not happy with using guesswork. :)

The script is from the help file with lots of things removed. I don't need horizontal scrolling and I also removed the funtion WM_SIZE because I couldn't understand it. Did I do something wrong?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIScrollBars.au3>
#include <ScrollBarConstants.au3>

;Opt("MustDeclareVars", 1)

_Main()

Func _Main()
    Local $nFileMenu, $nExititem, $GUIMsg, $hGUI, $h_cGUI
    Local $listview, $button

    $hGUI = GUICreate("ScrollBar Example", 400, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
    GUISetBkColor(0x88AABB)

    $hButton2 = GUICtrlCreateButton("Scroll", 10, 10, 90, 20)

    $h_cGUI = GUICreate("Child GUI", 380, 200, 8, 100, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)

    GUISetBkColor(0xFFFFFF)
    GUISetState()
    GUICtrlSetResizing($h_cGUI, $GUI_DOCKALL)

    GUISwitch($hGUI)

    ;GUIRegisterMsg($WM_SIZE, "WM_SIZE")
    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    ;GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

    GUISetState()

    _GUIScrollBars_Init($h_cGUI)
    _GUIScrollBars_ShowScrollBar($h_cGUI, $SB_HORZ, False)
    $j = 10
    _GUIScrollBars_SetScrollRange($h_cGUI, $SB_VERT, 0, 0)

    While 1
        $GUIMsg = GUIGetMsg()

        Switch $GUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hButton2
                GUISwitch($h_cGUI)
                For $i = 1 To 3000
                    GUICtrlCreateLabel($i & @CRLF & "Hello World", 10, $j, 70, 40)
                    _GUIScrollBars_SetScrollRange($h_cGUI, $SB_VERT, 0, $i*2.5 -12)
                    _GUIScrollBars_ShowScrollBar($h_cGUI, $SB_HORZ, False)
                    $j += 40
                Next
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>_Main

Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $index = -1, $yChar, $yPos
    Local $Min, $Max, $Page, $Pos, $TrackPos

    For $x = 0 To UBound($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $index = $x
            $yChar = $aSB_WindowInfo[$index][3]
            ExitLoop
        EndIf
    Next
    If $index = -1 Then Return 0


    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $nScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $Min)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $Max)

        Case $SB_LINEUP ; user clicked the top arrow
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)

        Case $SB_LINEDOWN ; user clicked the bottom arrow
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
    EndSwitch

;~    // Set the position and then retrieve it.  Due to adjustments
;~    //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($Pos <> $yPos) Then
        _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
        $yPos = $Pos
    EndIf

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_VSCROLL

Share this post


Link to post
Share on other sites

czardas,

Look at the ScrollBars UDF in my sig. It makes scrollbars a whole lot easier - in your case a single line! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

czardas,

Look at the ScrollBars UDF in my sig. It makes scrollbars a whole lot easier - in your case a single line! :)

M23

I see that my attempt to rewrite the help file example was not so succesful. It's unreliable and only works on the first few runs. I have downloaded the UDF and I'll look at it tomorrow. Thanks again.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Okay, I tried to get this working and I'm still having problems. I don't know if it's my code or not. Does anyone have any ideas what's wrong? The code is here:

I may have a solution to this now, but I'm not sure.

Edited by czardas

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

czardas,

Look in the Examples forum thread for explanations and an updated UDF. :)

M23

Edit: I see you found it already! ;)

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

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
Sign in to follow this  
Followers 0