Re: Resize a Listview
----- Original Message -----
From: <rml at rubis.trix.net>
To: "EUforum" <EUforum at topica.com>
Subject: Resize a Listview
>
>
> Hi people;
>
> Anyone could show to me (or indicated where I can found) how a
> Listview can be automatic resized when I resize a window ?
>
Assuming you are using win32lib.
The outside edge size of the listview is just a simple to resize as any
other control.
a) Create a handler for the w32HResize event for the containing Window.
b) In the handler code, get the new size of the window using
getClientSize(win).
c) Calculate the new size of the listview edges, based on whatever basis you
like.
d) call setRect(listview, ...) using the new calculated sizes and position
data.
The hard bit is working out how to change the width of the columns (assuming
a Report View listview). In one of my apps, I try to keep the relative
proportions the same, down to a minimum column size.
a) When you create the listview for the first time, record the size of it.
Then in the resize event handler...
b) Get the current widths of each column.
sequence colwid colwid = {}
for ColNum = 1 to ColumnCount do
colwid &= sendMessage(lv, LVM_GETCOLUMNWIDTH, ColNum-1, 0)
end for
c) Get the old size of the listview before the resize
d) Calc new listview size as in above method.
e) For each column, calc the new width as ( (NewSize/OldSize) * oldWidth)
colwid *= (NewSize/OldSize)
f) set The new column widths
for ColNum = 1 to ColumnCount do
VOID = sendMessage(lv, LVM_SETCOLUMNWIDTH, ColNum-1, colwid[ColNum]
* #FFFF)
end for
g) Save the listview size (OldSize) for the next resize event.
By the way, you can use these special values to set the widths...
LVSCW_AUTOSIZE -- Auto size to the column's current contents
LVSCW_AUTOSIZE_USEHEADER -- Auto size to the current heading text.
--
Derek
|
Not Categorized, Please Help
|
|