PDA

View Full Version : ListView control -> columns fixed width???



Oscar Ugolini
14-06-2012, 17:01
How can i fix the columns width in the ListView control???

please help me... :confused:
thanks all. :)

Oscar

Petr Schreiber
14-06-2012, 18:22
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

Oscar Ugolini
14-06-2012, 19:01
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

Petr Schreiber
15-06-2012, 00:25
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

ErosOlmi
15-06-2012, 08:03
Thanks a lot Petr
I will add as native

Oscar Ugolini
15-06-2012, 08:23
... i'll try it,
thanks Petr :)