INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Classes and Objects

A Changeable columns width listbox by viettla
Posted: 19 Oct 02

A Changeable columns width listbox
my original class is built on class desinger. For convenience,
I generated to PRG file by Class Brower. Pls rebuild on class designer
Properties:
ColumnCount > 1 (require)
ColumnWidth (optional)
MinimumWidth (optional)

**************************************************
*-- Class:        changeablecolwidthlst
*-- ParentClass:  listbox
*-- BaseClass:    listbox
*-- Time Stamp:   10/19/02 09:33:08 AM
*
DEFINE CLASS changeablecolwidthlst AS listbox


    ColumnCount = 2
    nmargin = ( (SYSMETRIC(3)))
    minimumwidth = 30
    ilmousestart = 0
    dragcol = 0
    Name = "changeablecolwidthlst"
    DIMENSION acolumnswidth[2]


    HIDDEN PROCEDURE stringtoarray
        LOCAL cString,cDelimited
        cString=ALLTRIM(this.ColumnWidths)
        cDelimited=[,]
        this.aColumnsWidth=0
        If Empty (cString)
            Return
        Endif

        If Right(cString,1) <> cDelimited
            cString=cString+cDelimited
        Endif

        nRow= Occur(cDelimited,cString)

        nStartPos=1
        For nRun=1 To nRow
            nEndPos=At(cDelimited,cString,nRun)
            If nEndPos >0
            lctemp=Subs(cString,nStartPos,nEndPos-nStartPos)
            this.aColumnsWidth(nRun)=VAL(ALLTRIM(lcTemp))
            Else
                Exit
            Endif
            nStartPos=nEndPos+1
        Endfor
    ENDPROC


    PROCEDURE MouseUp
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        this.DragCol=0
    ENDPROC


    PROCEDURE MouseDown
        Lparameters nButton, nShift, nXCoord, nYCoord
        Local nColwidth,nXobj
        nColwidth=0
        this.DragCol=0
        For i= 1 To This.ColumnCount-1
            nColwidth=nColwidth+ This.acolumnswidth(i)+2
            nXobj=nXCoord-This.Left - This.nMargin
            IF   Between(nXobj,nColwidth  - This.nMargin,nColwidth  + This.nMargin )
                this.DragCol=i
            Endif
        Endfor
    ENDPROC


    PROCEDURE Init
        IF this.ColumnCount =1
            this.ColumnCount=0
            return
        endif
        DIMENSION this.acolumnswidth(this.ColumnCount)
        this.stringtoarray()
        FOR i=1 TO this.ColumnCount
        IF this.aColumnsWidth(i)=0
                this.aColumnsWidth(i)=INT((this.width-this.nmargin)/this.ColumnCount)
        ENDIF
        DO WHILE  this.aColumnsWidth(i) <= this.nMargin*2
            this.aColumnsWidth(i)=this.aColumnsWidth(i)+this.nMargin
        ENDDO  
        THIS.ColumnWidths=THIS.ColumnWidths+IIF(i=1,"",",")+ allt(STR(this.aColumnsWidth(i)))
        ENDFOR
    ENDPROC


    PROCEDURE MouseMove
        Lparameters nButton, nShift, nXCoord, nYCoord
        LOCAL nColwidth,cColumnwidths,nXobj
        This.MousePointer = 0
        nColwidth=0
        cColumnwidths=""

        For i= 1 To This.ColumnCount-1
            nColwidth=nColwidth+ This.acolumnswidth(i)+2
            nXobj=nXCoord-This.Left - This.nMargin

            IF  Between(nXobj,nColwidth  - This.nMargin,nColwidth  + This.nMargin )
                This.MousePointer = 9
            ENDIF

            IF  i=this.DragCol
                    This.acolumnswidth(i)=This.acolumnswidth(i)+ (nXobj-nColwidth)
                    IF This.acolumnswidth(i) < This.minimumwidth
                        This.acolumnswidth(i)=This.minimumwidth
                    ENDIF
            Endif
            IF  this.DragCol <> 0
                cColumnwidths=cColumnwidths+Iif(i > 1,",","") + Alltrim(Str(This.acolumnswidth(i)))
            endif
        Endfor

        IF  this.DragCol <> 0
            This.ColumnWidths=cColumnwidths
        Endif
    ENDPROC


ENDDEFINE
*
*-- EndDefine: changeablecolwidthlst
**************************************************

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close