Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detect ListBox Scroll
Message
 
To
16/09/2006 09:38:56
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01154339
Message ID:
01154355
Views:
12
>Fabio
>Thanks. I have applied this technique on my Listbox and it is working as expected. The reason why I asked this question was that I have a Text box on the same form and I wanted the focus to return to this Textbox after the scrolling.
>i) Where do I put the Text1.Setfocus command now. I have put it on the List1.Scrolled Method and List1.TopIndex_Assign Method but it seems no to work throughout.
>
>ii) Also is it possible to make sure that as the user scrolls the 1st visible item is the one highlighted ?
>
>I hope I am not asking too much
>
>Fred


Based on Fabio's example:
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

    Caption = "show a Listbox Scrolled event"
    ShowWindow = 2
    Autocenter    = .T.

    ADD OBJECT list1 AS ListBoxEx WITH ;
        RowSourceType = 1, ;
        RowSource = "A,B,C,D,E,E,F,G,H,I,Y,T,Y,G,F,R,E,D,E,R,R,R,ED,E,E,E,E,E,SD,S,S", ;
        Height = 182, ;
        Left = 32, ;
        Top = 20, ;
        Width = 151

    ADD OBJECT TextBox1 AS TextBox WITH;
        LEFT = 200,;
        TOP  = 20,;
        WIDTH = 100

    PROCEDURE list1.Scrolled(items)
        WAIT windows "scrolled"+STR(m.items) NOWAIT
    ENDPROC

ENDDEFINE

DEFINE CLASS ListBoxEx As ListBox
    HIDDEN  TopIndexLast
        TopIndexLast = 1

    PROCEDURE MouseWheel
        LPARAMETERS nDirection, nShift, nXCoord, nYCoord
        * VFP have a design bug and NODEF + baseclass::MouseWheel doesn't work
        NODEFAULT
        *RETURN ListBox::MouseWheel(nDirection, nShift, nXCoord, nYCoord)
        this.TopIndex = m.this.TopIndex - SIGN(m.nDirection)
    ENDPROC

    PROCEDURE MouseUp
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        this.TopIndex=m.this.TopIndex
    ENDPROC    

    PROCEDURE InteractiveChange
        this.TopIndex=m.this.TopIndex
    ENDPROC

    HIDDEN PROCEDURE TopIndex_Assign(TopIndex)
        This.TopIndex = m.TopIndex
        TopIndex = m.this.TopIndex- This.TopIndexLast
        IF EMPTY(m.TopIndex )
            RETURN
        ENDIF
        This.TopIndexLast = m.this.TopIndex
********* only changes I made
        this.ListIndex = this.TopIndex
        thisform.TextBox1.Value = this.List(this.ListIndex)
*********
        RETURN this.Scrolled(m.TopIndex)

    PROCEDURE Scrolled(items)

ENDDEFINE
Is that what you want?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform