Post by esr on Nov 7, 2019 18:50:45 GMT 1
Topic: List View Object / column headers height / automatic height adjustment considering the display schemes of Windows ( Need support )!
Hi GFA Basic fans and freaks,
I am currently working on the List View presentation in GFA Basic. I would like to adjust a listview table in height so that only visible entries are displayed. For this purpose, the headline height of the table must be determined and then the individual line heights of the data lines must be added. The whole thing is still dependent on the frame width of the table and the display scheme of Windows. In the classical representation, the row height of the header is smaller than in the Aero representation.
To simplify the whole thing I created an ImageList object and set the image height to 20 pixel. Invited is a blank BMP-picture. This image is set as SmallIcon in each data row in the first column. Additional I've hidden this column over the column width and the value 0.
Accordingly, all rows should now be the same height.
Accordingly, all rows should now be the same height.
Now I have to add the width of the header and the frame size of the table. That was the idea! ... - For this I used a listing part of Peter Heinzig (height column header determination).
I tried to do this with the following example (see below). It does not work reliably.
At the latest from five lines, the table view shifts. - Who can help here?
I tried to do this with the following example (see below). It does not work reliably.
At the latest from five lines, the table view shifts. - Who can help here?
Since the listview should later be provided with graphics overlays, the distance must not shift and the vertikaler scrollbar should not be visible. - In addition, the program should also work on all computers and windows skins, so the table must be calculated in advance to gurantee a saftey presentation!
Later, many different data lines should be inserted (maximum 30 / minimum 1). Accordingly, the table height should be adjusted according to the entries.Here is the test- listing:
---------------------------------------------------------------------------------------------
Local anz%
Input "Wie viele Reihen:";anz
Local t%
LoadForm frm1
Ocx ImageList ilx : ilx.ImageWidth = 20 : ilx.ImageHeight = 20
Local Picture pic
Set pic = LoadPicture(":1") : ilx.AddPart , , pic, (0) * 20, 0
Set lv1.SmallIcons = ilx
lv1.View = 3 : lv1.FullRowSelect = 1 : lv1.HideSelection = 0
lv1.LabelEdit = 1 : lv1.MultiSelect = 0 : lv1.GridLines = 1
lv1.ColumnHeaders.Add( , , "").Width = 0
lv1.ColumnHeaders.Add( , , "").Width = 600
For t = 1 To anz : lv1.Add : lv1(t).AllText = ";" + Trim$(Str$(t)) : Next t
Local Int hwnd, chh, n, lvx, lvy
Type RECT : -Int x, y, w, h : End Type : Local re As RECT
Static Int linh
SendMessage lv1.hWnd, $100E, 1, re '$100E = LVM_GETITEMRECT
linh = re.h - re.y 'Linienhöhe das LV
hwnd = SendMessage(lv1.hWnd, $101F, 0, 0) '$101F = LVM_GETHEADER
~GetWindowRect(hwnd, re) : chh = re.h - re.y 'Höhe ColumnHeader
~GetClientRect(lv1.hWnd, re) : n = (lv1.Height - re.h) / 2 're: Innenbereich LV, n: Randbreite
lvx = lv1.Left + n : lvy = lv1.Top + n + chh - linh 'Position der ersten Zeile in LV
'lv1.Height = (lv1.Top + n + chh + linh) + (anz * re.h)
lv1.Height = (lv1.Top + chh + linh) + (anz * ilx.ImageHeight)
Do
Sleep
Until Me Is Nothing
Input "Wie viele Reihen:";anz
Local t%
LoadForm frm1
Ocx ImageList ilx : ilx.ImageWidth = 20 : ilx.ImageHeight = 20
Local Picture pic
Set pic = LoadPicture(":1") : ilx.AddPart , , pic, (0) * 20, 0
Set lv1.SmallIcons = ilx
lv1.View = 3 : lv1.FullRowSelect = 1 : lv1.HideSelection = 0
lv1.LabelEdit = 1 : lv1.MultiSelect = 0 : lv1.GridLines = 1
lv1.ColumnHeaders.Add( , , "").Width = 0
lv1.ColumnHeaders.Add( , , "").Width = 600
For t = 1 To anz : lv1.Add : lv1(t).AllText = ";" + Trim$(Str$(t)) : Next t
Local Int hwnd, chh, n, lvx, lvy
Type RECT : -Int x, y, w, h : End Type : Local re As RECT
Static Int linh
SendMessage lv1.hWnd, $100E, 1, re '$100E = LVM_GETITEMRECT
linh = re.h - re.y 'Linienhöhe das LV
hwnd = SendMessage(lv1.hWnd, $101F, 0, 0) '$101F = LVM_GETHEADER
~GetWindowRect(hwnd, re) : chh = re.h - re.y 'Höhe ColumnHeader
~GetClientRect(lv1.hWnd, re) : n = (lv1.Height - re.h) / 2 're: Innenbereich LV, n: Randbreite
lvx = lv1.Left + n : lvy = lv1.Top + n + chh - linh 'Position der ersten Zeile in LV
'lv1.Height = (lv1.Top + n + chh + linh) + (anz * re.h)
lv1.Height = (lv1.Top + chh + linh) + (anz * ilx.ImageHeight)
Do
Sleep
Until Me Is Nothing
---------------------------------------------------------------------------------------------
Annotation: Form1 (frm1) beinhaltet nur ein listview- Objekt (Name lv1).
I hope that some of you know about the Listview object and know what to do to get a working and acceptable solution. That would be very helpful for me and would help me to continue my main program!
Thanks in advance.