Announcement

Collapse
No announcement yet.

How do you hide listview scroll bars?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do you hide listview scroll bars?

    Hi Fellows,

    I am doing a small project using listview controls. I want to
    suppress the working and showing of the scroll bars belonging
    to the listview window and using scrollbar controls instead.
    I have tried to use the ShowScrollBar function which can be used
    to show or hide scroll bars – both scroll bar controls and standard
    scroll bars belonging to a window. However, it is not working.
    I cannot hide the standard scroll bars of the listview window.
    Can you help me? Is there another method which works?
    Thank you in advance.

    Best regards,

    Erik


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

  • #2
    NOT TESTED, but maybe you have to set the style?

    From MDSN:
    LVS_NOSCROLL
    Scrolling is disabled. All items must be within the client area. This style is not compatible with the LVS_LIST or LVS_REPORT styles. See Knowledge Base Article Q137520 for further discussion.
    MCM

    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Eric --

      Remembered one simple method - to place inside another window.

      Code:
         #Compile Exe
         #Register None
         #Dim All
         #Include "COMMCTRL.INC"
      
         %ID_LISTVIEW = 101
         %ID_BUTTON   = 102
      
         CallBack Function DlgProc1
            Local i As Long, j As Long, zText As Asciiz * 100
            Local lvc As LV_COLUMN
            Local rc As RECT
            Local lvi As LV_ITEM
            Static hList As Long
      
            Select Case CbMsg
               Case %WM_INITDIALOG
                  Local icc As INIT_COMMON_CONTROLSEX
                  icc.dwSize = SizeOf(icc)
                  icc.dwICC = %ICC_LISTVIEW_CLASSES
                  InitCommonControlsEx icc
      
                  GetClientRect CbHndl, rc
                  hList = CreateWindowEx(0, "SysListView32", ByVal 0, _
                     %WS_CHILD Or %WS_VISIBLE Or %LVS_REPORT, 0, 0, _
                     rc.nRight + GetSystemMetrics(%SM_CXVSCROLL), _
                     rc.nBottom + GetSystemMetrics(%SM_CYHSCROLL), _
                     CbHndl, %ID_LISTVIEW, GetModuleHandle(""), ByVal 0)
      
                  i = SendMessage (hList, %ID_LISTVIEW, %LVM_GETEXTENDEDLISTVIEWSTYLE, 0)
                  i = i Or %LVS_EX_GRIDLINES Or %LVS_EX_FULLROWSELECT
                  SendMessage hList, %LVM_SETEXTENDEDLISTVIEWSTYLE, 0, i
                  
                  GetClientRect hList, rc
      
      
                  lvc.mask = %LVCF_FMT Or %LVCF_WIDTH Or %LVCF_TEXT Or %LVCF_SUBITEM
                  lvc.fmt = %LVCFMT_LEFT
      
                  %nCol = 25
                  %nRow = 100
                  lvc.cx = rc.nRight * 0.25
                  lvc.cchTextMax = SizeOf(zText)
                  lvc.pszText = VarPtr(zText)
                  For i = 1 To %nCol
                     zText = "Column" + Str$(i)
                     SendMessage hList, %LVM_INSERTCOLUMN, i, VarPtr(lvc)
                  Next
      
                  lvi.mask = %LVIF_TEXT
                  lvi.pszText = VarPtr(zText)
                  For i = 1 To %nRow
                     lvi.iItem = i - 1
                     For j = 1 To %nCol
                        zText = "Row " + Format$(i, "000") + ", Col " + Format$(j, "000")
                        lvi.iSubItem = j - 1
                        If j = 1 Then ListView_InsertItem hList, lvi Else ListView_SetItem hList, lvi
                     Next
                  Next
            End Select
         End Function
         
         CallBack Function DlgProc
            Select Case CbMsg
                Case %WM_INITDIALOG
                   Local hDlgLv As Long
                   Dialog New CbHndl, "", 10, 10, 280, 150, %WS_CHILD Or %WS_VISIBLE, %WS_EX_CLIENTEDGE To hDlgLv
                   Dialog Show Modeless hDlgLv Call DlgProc1
                   Control Add Button, CbHndl, %ID_BUTTON, "Nothing", 110, 170, 80, 15
                   SetFocus hDlgLV
            End Select
         End Function
      
         Function PbMain
            Local hDlg As Long
            Dialog New 0, "ListView", ,, 300, 200, _
               %WS_OVERLAPPEDWINDOW Or %WS_CAPTION To hDlg
            Dialog Show Modal hDlg Call DlgProc
         End Function

      [This message has been edited by Semen Matusovski (edited October 20, 2001).]

      Comment


      • #4
        Michael, Semen,

        Thanks a lot for your feed-back. Since I need to use the
        %LVS_REPORT style it seems that %LVS_NOSCROLL would not be
        compatible according to Michael’s information.

        The solution provided by you Semen is indeed very elegant and
        works perfectly. I will study it more closely. I will no doubt
        be able to use the principles in my project. Thank you very much.

        Best regards,

        Erik




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

        Comment

        Working...
        X