Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Changeable columns width listbox

Classes and Objects

A Changeable columns width listbox

by  viettla  Posted    (Edited  )
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
**************************************************
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top