Page 1 of 1
Possible to CALCULATE a listbox-height ?
Posted: Tue Apr 23, 2019 12:05 pm
by ukoenig
Is it possible to calculate the needed listbox-height
to show ALL items without using a scrollbar ?
I tested to calculate the row-height with the defined font
and 5 and 10 items but getting no exact results
.............
nRowHeight := oListFont:nHeight + 4.8 // font-height + top and bottom-space
nBrwHeight := nRowHeight * LEN( aItems ) // tested with 10 and 5 items
@ 5, 5 LISTBOX oLbx VAR cItem ITEMS aItems ;
SIZE nBrwWidth,
nBrwHeight PIXEL OF oDlg
the total height
nDlgHeight := nBrwHeight + 45 ( extra space for the defined button )
-------------
regards
Uwe
Re: Possible to CALCULATE a listbox-height ?
Posted: Tue Apr 23, 2019 12:29 pm
by nageswaragunupudi
Re: Possible to CALCULATE a listbox-height ?
Posted: Tue Apr 23, 2019 1:17 pm
by ukoenig
Thank You very much.
It is working now without scrollbars and perfect adjustment adding
#define LB_GETITEMHEIGHT 0x01A1
nItemHeight := oLbx:SendMsg( LB_GETITEMHEIGHT, 0, 0 )
adding bitmaps the browser-hight is calculated with the bitmap-height
even if the normal itemhight > bitmap-height
that means the item-hight is defined with the bitmap-height
the normal item-hight from above = 18
the bitmap-hight = 16
regards
Uwe
Re: Possible to CALCULATE a listbox-height ?
Posted: Wed Apr 24, 2019 12:56 pm
by ukoenig
I noticed a problem to SEEK inside a listbox with included images
using the same items without images the seek works
The listbox with images selects position Bbb at opening
typing a, c, d or e the focus goes to top and nothing happens.
regards
Uwe
Re: Possible to CALCULATE a listbox-height ?
Posted: Wed Apr 24, 2019 1:50 pm
by dutch
Dear Uwe,
How you calculate Listbox Height. May I have an example?
ukoenig wrote:Thank You very much.
It is working now without scrollbars and perfect adjustment adding
#define LB_GETITEMHEIGHT 0x01A1
nItemHeight := oLbx:SendMsg( LB_GETITEMHEIGHT, 0, 0 )
adding bitmaps the browser-hight is calculated with the bitmap-height
even if the normal itemhight > bitmap-height
that means the item-hight is defined with the bitmap-height
the normal item-hight from above = 18
the bitmap-hight = 16
regards
Uwe
Re: Possible to CALCULATE a listbox-height ?
Posted: Wed Apr 24, 2019 2:20 pm
by ukoenig
The calculation with and without images.
( I will post a complete working sample )
Code: Select all
#define LB_GETITEMHEIGHT 0x01A1
...
...
...
@ nBtnTop, nBtnleft BTNBMP oBtn OF oDlg ;
SIZE 60, 28 PIXEL 2007 ; // B / H
PROMPT "&Cancel" ;
ACTION oDlg:End() ;
FONT oListFont CENTER BORDER
// calculate the browser-size and dialog-size adjusted to the browser
ACTIVATE DIALOG oDlg ;
ON INIT ( nItemHeight := oLbx:SendMsg( LB_GETITEMHEIGHT, 0, 0 ), ; // get the item-height
IIF( nImgHeight = 0, nBrwHeight := nItemHeight * ( LEN( aItems ) +1), ; // browser-hight NO images defined
nBrwHeight := nImgHeight * ( LEN( aItems ) +1) ), ; // browser-hight WITH images
oLbx:nHeight := nBrwHeight, oLbx:Refresh(), ; // defined browser height from calculation
oDlg:Move( 0, 0, nBrwWidth +23, nBrwHeight + 45, .t. ), ; // adjusted dialog-hight to browser
oBtn:nTop := oDlg:nHeight -50, oBtn:Refresh(), ; // button-vertical-position
oCol:AnchorToCell( oDlg ), oDlg:SetColor( 0, nColor ) ) // connect the sub-dialog to the main xbrowse-cell
regards
Uwe
Re: Possible to CALCULATE a listbox-height ?
Posted: Thu Apr 25, 2019 3:08 am
by dutch
Dear Uwe,
Thanks so much.
Dutch
Re: Possible to CALCULATE a listbox-height ?
Posted: Sun Apr 28, 2019 4:53 pm
by ukoenig
Now date-, logical- and numeric fields are supported as well using cell-connection.
Using date-fields the needed size-result belongs to a fixed calculation because
of the wanted 3 buttons.
regards
Uwe
Re: Possible to CALCULATE a listbox-height ?
Posted: Sun Apr 28, 2019 5:39 pm
by nageswaragunupudi
The easiest way to anchor a dialog to a cell is
ACTIVATE DIALOG oDlg ON INIT oBrw:SelectedCol():AnchorToCell( oDlg )
Re: Possible to CALCULATE a listbox-height ?
Posted: Sun Apr 28, 2019 6:01 pm
by ukoenig
Mr. Rao,
I will post the complete solution
it is the way I'm doing it using :
:bEditBlock := { | nRow, nCol,
oCol, nKey | ;
FUNCTION MYCELLDLG( oBrw, nRow, nCol,
oCol, nKey, aItems, aImages, nImgHeight, oListFont, nColor )
....
....
ON INIT ( some calculations....
and at the end :
oCol:AnchorToCell( oDlg ) )
RETURN cRet
regards
Uwe