KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility code to show and hide the List box horizontal scrollbar
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: June 20, 2012

If you desire to show or hide the horizontal scrollbar to a list box based on the width of the list box compared sum of the initial column widths. The following form method code will show and hide the horizontal scrollbar during a form resize:

Case of
: (Form event=On Resize)
    OBJECT GET COORDINATES(ListForm_L;$Left_L;$Top_L;$Right_L;$Bottom_L)
    $width_l:=($Right_L-$Left_L)

    OBJECT SET SCROLLBAR(ListForm_L;($width_l < WidthOfCols_L);True)

: (Form event=On Load)
    C_LONGINT(WidthOfCols_L)
    ARRAY TEXT($ColNames_at;0)
    ARRAY TEXT($HeaderNames_at;0)
    ARRAY POINTER($ColVars_ap;0)
    ARRAY POINTER($HeaderVars_ap;0)
    ARRAY BOOLEAN($ColsVisible_ab;0)
    ARRAY POINTER($Styles_ap;0)

    LISTBOX GET ARRAYS(ListForm_L;\
      $ColNames_at;$HeaderNames_at;\
      $ColVars_ap;\
      $HeaderVars_ap;\
      $ColsVisible_ab;\
      $Styles_ap)

    ARRAY LONGINT($ColWidths_aL;Size of array($ColVars_ap))

    For ($Ndx;1;Size of array($ColVars_ap))
       $ColWidths_aL{$Ndx}:=LISTBOX Get column width(*;$ColNames_at{$Ndx})
    End for

    WidthOfCols_L:=Sum($ColWidths_aL)

End case

Commented by Charlie Vass on June 20, 2012 at 1:27 PM
Code has been corrected in both the On Load and On Rezize code.
Commented by Leonard Soloniuk on June 17, 2012 at 5:03 PM
This code doesn't work in v13. WidthOfCols_L is always equal to 0.Trying to debug the code by placing breakpoints in the On Resize handler, causes 4D to hang.