Results 1 to 6 of 6

Thread: ListView control -> columns fixed width???

  1. #1
    Junior Member
    Join Date
    May 2012
    Location
    Cesena
    Age
    45
    Posts
    29
    Rep Power
    8

    ListView control -> columns fixed width???

    How can i fix the columns width in the ListView control???

    please help me...
    thanks all.

    Oscar

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,812
    Blog Entries
    3
    Rep Power
    695
    Hi Oscar,

    you should be able to finetune the width using the ListView_SetColumnWidth function.
    For more details, open ThinAir, press F1 and into Index tab enter ListView_SetColumnWidth.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    Junior Member
    Join Date
    May 2012
    Location
    Cesena
    Age
    45
    Posts
    29
    Rep Power
    8

    i see it ... but

    i'm looking for a tip to block the columns width,
    so you can't resize them with mouse...

    thanks for reply Petr,
    bye
    Oscar

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,812
    Blog Entries
    3
    Rep Power
    695
    Ha!,

    my apologies, I understood your request wrong...

    Well, thinBASIC does not have native function to do that, but the good news is we can prepare custom function to do this for us.
    Just add this function to your code:
      Function DisableListviewColumnResize( hDlg As DWord, ctlListview As DWord )
      
        Long hHeader
        ' -- Win32 messages
        Long LVM_GETHEADER   = %LVM_FIRST + 31
        Long HDS_NOSIZING    = &H0800
        
        ' -- Mirror, mirror on the wall, who's the header of them all?
        Control Send hDlg, ctlListview, LVM_GETHEADER, 0, 0 To hHeader
                        
        ' -- Retrieve header style and modify it                    
        Long styleOld = Win_GetWindowLong(hHeader, %GWL_STYLE)
        Long styleNew = styleOld Or HDS_NOSIZING
        
        Win_SetWindowLong(hHeader, %GWL_STYLE, styleNew)
      
      End Function
    
    And then, somewhere, call it like:
    DisableListviewColumnResize( hDlg, %myListview )
    
    (hDlg = handle of dialog, %myListview = your listview control ID)

    I tested it on my PC, it works, but beware, this functionality is quite new to Win32 API, so it is available from Windows XP up (it will not make effect on earlier Windows).


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,281
    Blog Entries
    2
    Rep Power
    10
    Thanks a lot Petr
    I will add as native
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  6. #6
    Junior Member
    Join Date
    May 2012
    Location
    Cesena
    Age
    45
    Posts
    29
    Rep Power
    8

    well done!...

    ... i'll try it,
    thanks Petr

Similar Threads

  1. Listview DB module
    By jjcmmgb in forum Suggest new module
    Replies: 1
    Last Post: 31-05-2011, 22:09
  2. Listview %lvn_keydown
    By martin in forum thinBasic General
    Replies: 18
    Last Post: 02-09-2009, 14:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •