Possible to CALCULATE a listbox-height ?

Post Reply
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Possible to CALCULATE a listbox-height ?

Post 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 )

-------------

Image

regards
Uwe :?:
Last edited by ukoenig on Wed Apr 24, 2019 2:36 pm, edited 2 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Possible to CALCULATE a listbox-height ?

Post by nageswaragunupudi »

Regards

G. N. Rao.
Hyderabad, India
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Possible to CALCULATE a listbox-height ?

Post 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 )


Image

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

Image

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Possible to CALCULATE a listbox-height ?

Post 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.

Image

regards
Uwe :?:
Last edited by ukoenig on Sun Apr 28, 2019 4:52 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Possible to CALCULATE a listbox-height ?

Post 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 )


Image

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

Image

regards
Uwe :D
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Possible to CALCULATE a listbox-height ?

Post 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 :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Possible to CALCULATE a listbox-height ?

Post by dutch »

Dear Uwe,

Thanks so much.
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Possible to CALCULATE a listbox-height ?

Post 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.

Image

regards
Uwe :?:
Last edited by ukoenig on Mon Apr 29, 2019 6:55 am, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Possible to CALCULATE a listbox-height ?

Post by nageswaragunupudi »

The easiest way to anchor a dialog to a cell is

ACTIVATE DIALOG oDlg ON INIT oBrw:SelectedCol():AnchorToCell( oDlg )
Regards

G. N. Rao.
Hyderabad, India
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: Possible to CALCULATE a listbox-height ?

Post 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 :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
Post Reply