Results 1 to 6 of 6

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

  1. #1
    Member
    Join Date
    May 2012
    Location
    Predappio
    Age
    51
    Posts
    34
    Rep Power
    15

    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
    7,128
    Rep Power
    732
    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 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    Member
    Join Date
    May 2012
    Location
    Predappio
    Age
    51
    Posts
    34
    Rep Power
    15

    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
    7,128
    Rep Power
    732
    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 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Thanks a lot Petr
    I will add as native
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    Member
    Join Date
    May 2012
    Location
    Predappio
    Age
    51
    Posts
    34
    Rep Power
    15

    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

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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