Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 14, 2020 13:04:47 GMT -5
Has anyone ever done anything colour wise with a listview row? I'd like to be able to set a specific colour for a listview row. I'm also unsure whether this would automatically move as new items are added or whether it would stay static. Apparently it can be done, But I'm unsure of how to implement this? docs.microsoft.com/en-us/windows/win32/controls/lvm-setbkcolor
|
|
|
Post by Chris Iverson on Dec 14, 2020 14:23:14 GMT -5
I think that message might set the background color for the whole control, and not just one row.
It's a window message; it gets sent to the window using the SendMessageA API call.
I think it would be used something like this(assuming hListView is the handle to a listview control):
LVM.SETBKCOLOR = hexdec("1001")
red = 128 blue = 240 green = 10
colorref = (red * 65536) + (blue * 256) + green
CallDLL #user32, "SendMessageA",_ hListView as ulong,_ LVM.SETBKCOLOR as long,_ 0 as long,_ colorref as ulong,_ ret as long
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 15, 2020 12:25:45 GMT -5
Yes you're right SETBKCOLOR is for the background, I think LVM_SETTEXTBKCOLOR is actually for the row, however I've tried (and obvs failed) to set even the background and row colours to no avail. I also don't know where you're getting the hex value from? I don't see any reference to it in the docsI'm just using the standard ListView code posted by metro link. I've added SETBKCOLOR to the listview constants etc, but clearly way beyond my ability! NoMainWin Global False : False = 0 Global True : True = 1 Global currentRow : currentRow = 0
listViewHandle(0) = _NULL
'LVM.SETBKCOLOR = hexdec("1001")
red = 28 blue = 240 green = 10 colorref = (red * 65536) + (blue * 256) + green
Call initializeListViewConstants
WindowWidth = 530 WindowHeight = 335 Button #Example.btnAddItem, "Add Item", AddItem, UL, 5, (WindowHeight - 65) Button #Example.btnEditItem, "Edit Item", EditItem, UL, 202.5, (WindowHeight - 65) Button #Example.btnDeleteItem, "Delete Item", DeleteItem, UL, 405, (WindowHeight - 65)
Open "ListView Example" For Window As #Example Call InitCommonControls style = _WS_CHILD Or _WS_VISIBLE Or listViewConstants.LVS.NOSORTHEADER.struct _ Or listViewConstants.LVS.REPORT.struct Or listViewConstants.LVS.SHOWSELALWAYS.struct _ Or listViewConstants.LVS.SINGLESEL.struct styleEx = _WS_EX_CLIENTEDGE Or _WS_EX_DLGMODALFRAME 'Or listViewConstants.LVS.EX.DOUBLEBUFFER.struct listViewHandle(0) = CreateListView(style, styleEx, Hwnd(#Example), GetWindowLong(Hwnd(#Example), _GWL_HINSTANCE), 5, 23, 505, 244) result = setListViewFullRowSelect(listViewHandle(0)) result = listViewShowGrid(listViewHandle(0)) result = createNewListColumn(listViewHandle(0), 0, 100, " Item 1") result = createNewListColumn(listViewHandle(0), 1, 100, " Item 2") result = createNewListColumn(listViewHandle(0), 2, 100, " Item 3") #Example "TrapClose Quit"
'Various tries! CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKCOLOR as long, 0 as long, colorref as ulong, ret as long
result = SendMessageLVITEMStruct(hListView, LVM.SETBKCOLOR, colorref)
result = SendMessageLVITEMStruct(hListView, listViewConstants.LVM.SETBKCOLOR.struct, colorref)
While Hwnd(#Example) Scan
Wend
Sub Quit handle$ result = DestroyWindow(listViewHandle(0)) Close #handle$ End End Sub
Sub AddItem handle$ result = AddListViewData(listViewHandle(0), currentRow, 0, "Data1") result = EditListViewData(listViewHandle(0), currentRow, 1, "Data2") result = EditListViewData(listViewHandle(0), currentRow, 2, "Data3") result = SelectListViewRow(listViewHandle(0), currentRow, True) currentRow = (currentRow + 1) End Sub
Sub EditItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) item1$ = GetListViewText$(listViewHandle(0), row, 0) item2$ = GetListViewText$(listViewHandle(0), row, 1) item3$ = GetListViewText$(listViewHandle(0), row, 2)
'result = EditListViewData(listViewHandle(0), row, 0, GetListViewText$(listViewHandle(0), row, 0)
result = EditListViewData(listViewHandle(0), row, 0, GetListViewText$(listViewHandle(0), row, 0) + " Edited") result = EditListViewData(listViewHandle(0), row, 1, GetListViewText$(listViewHandle(0), row, 1) + " Edited") result = EditListViewData(listViewHandle(0), row, 2, GetListViewText$(listViewHandle(0), row, 2) + " Edited")
result = SelectListViewRow(listViewHandle(0), row, True) End Sub
Sub DeleteItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) result = SendMessageLVITEMStruct(listViewHandle(0), listViewConstants.LVM.DELETEITEM.struct, row) currentRow = (currentRow - 1) End Sub
Sub InitCommonControls CallDLL #comctl32, "InitCommonControls", ret As void End Sub
Sub initializeListViewConstants 'Create the structs for ListViews
Struct LVITEM, mask As ulong, _ iItem As long, _ iSubItem As long, _ state As ulong, _ stateMask As ulong,_ pszText As ptr, _ cchTextMax As long, _ iImage As long, _ lParam As long, _ iIndent As long
Struct LVCOLUMN, mask As ulong, _ fmt As long, _ cx As long, _ pszText As ptr, _ cchTextMax As long, _ iSubItem As long, _ iImage As long, _ iOrder As long
Struct LVFINDINFO, flags As ulong, _ psz As ptr, _ lParam As ulong, _ pt As ulong, _ 'point structure vkDirection As ulong
Struct listViewConstants, LVP.DBLCLK As long, _ LVS.REPORT As long, _ LVS.SINGLESEL As long, _ LVS.SHOWSELALWAYS As long, _ LVS.NOSORTHEADER As long, _ LVS.EXDOUBLEBUFFER As long, _ LVS.EX.FULLROWSELECT As long, _ LVS.EX.CHECKBOXES As long, _ LVIS.FOCUSED As long, _ LVIS.UNSELECTED As long, _ LVIS.SELECTED As long, _ LVIS.CHECKED As long, _ LVIS.UNCHECKED As long, _ LVIS.STATEIMAGEMASK As long, _ LVIF.TEXT As long, _ LVIF.STATE As long, _ LVIR.BOUNDS As long, _ LVFI.STRING As long, _ LVFI.PARTIAL As long, _ LVN.ITEMCHANGED As long, _ LVM.ENSUREVISIBLE As long, _ LVM.SETITEMSTATE As long, _ LVM.GETITEMSTATE As long, _ LVM.GETITEMTEXT As long, _ LVM.FINDITEMA As long, _ LVM.SETITEM As long, _ LVM.GETITEMCOUNT As long, _ LVM.GETITEMA As long, _ LVM.GETSUBITEMRECT As long, _ LVM.DELETEITEM As long, _ LVM.INSERTITEM As long, _ LVM.INSERTCOLUMN As long, _ LVM.SETEXTENDEDLISTVIEWSTYLE As long, _ LVM.SETBKCOLOR As long
'LVM_FIRST = &H1000 or 4096 listViewConstants.LVP.DBLCLK.struct = False listViewConstants.LVS.REPORT.struct = 1 listViewConstants.LVS.SINGLESEL.struct = 4 listViewConstants.LVS.SHOWSELALWAYS.struct = 8 listViewConstants.LVS.NOSORTHEADER.struct = 32768 listViewConstants.LVS.EXDOUBLEBUFFER.struct = 10000 listViewConstants.LVS.EX.FULLROWSELECT.struct = 32 listViewConstants.LVS.EX.CHECKBOXES.struct = 4 listViewConstants.LVIS.FOCUSED.struct = 1 listViewConstants.LVIS.UNSELECTED.struct = 0 listViewConstants.LVIS.SELECTED.struct = 2 listViewConstants.LVIS.CHECKED.struct = 8192 listViewConstants.LVIS.UNCHECKED.struct = 4096 listViewConstants.LVIS.STATEIMAGEMASK.struct = 61440 listViewConstants.LVIF.TEXT.struct = 1 listViewConstants.LVIF.STATE.struct = 8 listViewConstants.LVIR.BOUNDS.struct = 0 listViewConstants.LVFI.STRING.struct = 2 listViewConstants.LVFI.PARTIAL.struct = 8 listViewConstants.LVN.ITEMCHANGED.struct = -101 listViewConstants.LVM.ENSUREVISIBLE.struct = 4115 listViewConstants.LVM.SETITEMSTATE.struct = 4139 listViewConstants.LVM.GETITEMSTATE.struct = 4140 listViewConstants.LVM.GETITEMTEXT.struct = 4141 listViewConstants.LVM.FINDITEMA.struct = 4109 listViewConstants.LVM.SETITEM.struct = 4102 listViewConstants.LVM.GETITEMCOUNT.struct = 4100 listViewConstants.LVM.GETITEMA.struct = 4101 listViewConstants.LVM.GETSUBITEMRECT.struct = 4152 listViewConstants.LVM.DELETEITEM.struct = 4104 listViewConstants.LVM.INSERTITEM.struct = 4103 listViewConstants.LVM.INSERTCOLUMN.struct = 4123 listViewConstants.LVM.SETEXTENDEDLISTVIEWSTYLE.struct = 4150 listViewConstants.LVM.SETBKCOLOR = 4097 'hexdec("1001") End Sub
Function CreateListView(ByRef style, ByRef styleEx, ByRef hParent, ByRef hInstance, ByRef xloc, ByRef yloc, ByRef width, ByRef height) className$ = "SysListView32" + chr$(0) CallDLL #user32, "CreateWindowExA", styleEx As ulong, _ ' extended style className$ As ptr, _ ' class name "" As ptr, _ style As ulong, _ ' style xloc As long, _ ' left x yloc As long, _ ' top y width As long, _ ' width height As long, _ ' height hParent As ulong, _ ' parent hWnd _NULL As ulong, _ hInstance As ulong, _ ' hInstance _NULL As ulong, _ CreateListView As ulong 'Hwnd to ListView
'LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT End Function
Function GetWindowLong(hWnd, index) CallDLL #user32, "GetWindowLongA", hWnd As ulong, _ index As long, _ GetWindowLong As long End Function
Function GetListViewItemCount(hWndLV) GetListViewItemCount = SendMessage(hWndLV, listViewConstants.LVM.GETITEMCOUNT.struct, 0, 0) End Function
Function createNewListColumn(hListView, columnIndex, columnWidth, headerCaption$) LVCOLUMN.cx.struct = columnWidth LVCOLUMN.pszText.struct = headerCaption$ LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT createNewListColumn = SendMessageLVCOLUMNStruct(hListView, listViewConstants.LVM.INSERTCOLUMN.struct, columnIndex) End Function
Function AddListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.INSERTITEM.struct, 0) AddListViewData = SendMessage(hWndLV, listViewConstants.LVM.GETITEMSTATE.struct, 0, 0) End Function
Function EditListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function SelectListViewRow(hWndLV, row, setFocus) LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.state.struct = listViewConstants.LVIS.SELECTED.struct If setFocus = True Then LVITEM.state.struct = (LVITEM.state.struct Or listViewConstants.LVIS.FOCUSED.struct) End If 'SelectListViewRow = SetFocus(hWndLV) SelectListViewRow = SendMessage(hWndLV, listViewConstants.LVM.ENSUREVISIBLE.struct, row, False) SelectListViewRow = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function setListViewFullRowSelect(hListView) setListViewFullRowSelect = SendMessage(hListView, 4150, 32, 32)'LVS_EX_FULLROWSELECT End Function
Function listViewShowGrid(hListView) listViewShowGrid = SendMessage(hListView, 4150, 1, 1)'LVS_EX_GRIDLINES End Function
Function SendMessage(hWnd, Msg, wParam, lParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ lParam As long, _ SendMessage As long End Function
Function SendMessageLVITEMStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVITEM As struct, _ SendMessageLVITEMStruct As long End Function
Function SendMessageLVCOLUMNStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVCOLUMN As struct, _ SendMessageLVCOLUMNStruct As long End Function
Function DestroyWindow(hWnd) CallDLL #user32, "DestroyWindow", hWnd As ulong, _ DestroyWindow As long End Function
Function GetSelectedListViewRow(hWndLV) GetSelectedListViewRow = -1
numListViewEntries = GetListViewItemCount(hWndLV) For row = 0 To (numListViewEntries - 1) LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 'first column LVITEM.stateMask.struct = listViewConstants.LVIS.SELECTED.struct result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMA.struct, 0) If LVITEM.state.struct And listViewConstants.LVIS.SELECTED.struct Then GetSelectedListViewRow = row Exit Function Else If row = (numListViewEntries - 1) Then GetSelectedListViewRow = -1 Exit Function End If End If Next row
End Function
Function GetListViewText$(hWndLV, row, column) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iSubItem.struct = column LVITEM.pszText.struct = Space$(_MAX_PATH) + chr$(0) LVITEM.cchTextMax.struct = Len(Winstring(LVITEM.pszText.struct)) EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMTEXT.struct, row) GetListViewText$ = Trim$(Winstring(LVITEM.pszText.struct)) End Function
|
|
|
Post by Chris Iverson on Dec 15, 2020 13:03:31 GMT -5
It worked for me when I un-commented-out the declaration of LVM.SETBKCOLOR, and set hListView to the list view handle, as I stated earlier.
I did mess up the color calculation, though; I got it backwards!
It's corrected in this example.
'NoMainWin Global False : False = 0 Global True : True = 1 Global currentRow : currentRow = 0
listViewHandle(0) = _NULL
'Need this to be set LVM.SETBKCOLOR = hexdec("1001")
red = 128 blue = 240 green = 10
'Color calc was backwards. Byte order in a COLORREF is apparently ABGR, 'and I don't think the alpha channel is actually used. colorref = (blue * (256 ^ 2)) + (green * 256) + red
Call initializeListViewConstants
WindowWidth = 530 WindowHeight = 335 Button #Example.btnAddItem, "Add Item", AddItem, UL, 5, (WindowHeight - 65) Button #Example.btnEditItem, "Edit Item", EditItem, UL, 202.5, (WindowHeight - 65) Button #Example.btnDeleteItem, "Delete Item", DeleteItem, UL, 405, (WindowHeight - 65)
Open "ListView Example" For Window As #Example Call InitCommonControls style = _WS_CHILD Or _WS_VISIBLE Or listViewConstants.LVS.NOSORTHEADER.struct _ Or listViewConstants.LVS.REPORT.struct Or listViewConstants.LVS.SHOWSELALWAYS.struct _ Or listViewConstants.LVS.SINGLESEL.struct styleEx = _WS_EX_CLIENTEDGE Or _WS_EX_DLGMODALFRAME 'Or listViewConstants.LVS.EX.DOUBLEBUFFER.struct listViewHandle(0) = CreateListView(style, styleEx, Hwnd(#Example), GetWindowLong(Hwnd(#Example), _GWL_HINSTANCE), 5, 23, 505, 244) result = setListViewFullRowSelect(listViewHandle(0)) result = listViewShowGrid(listViewHandle(0)) result = createNewListColumn(listViewHandle(0), 0, 100, " Item 1") result = createNewListColumn(listViewHandle(0), 1, 100, " Item 2") result = createNewListColumn(listViewHandle(0), 2, 100, " Item 3") #Example "TrapClose Quit"
'Various tries!
'Set hListView to the list view handle value hListView = listViewHandle(0) CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKCOLOR as long, 0 as long, colorref as ulong, ret as long
While Hwnd(#Example) Scan
Wend
Sub Quit handle$ result = DestroyWindow(listViewHandle(0)) Close #handle$ End End Sub
Sub AddItem handle$ result = AddListViewData(listViewHandle(0), currentRow, 0, "Data1") result = EditListViewData(listViewHandle(0), currentRow, 1, "Data2") result = EditListViewData(listViewHandle(0), currentRow, 2, "Data3") result = SelectListViewRow(listViewHandle(0), currentRow, True) currentRow = (currentRow + 1) End Sub
Sub EditItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) item1$ = GetListViewText$(listViewHandle(0), row, 0) item2$ = GetListViewText$(listViewHandle(0), row, 1) item3$ = GetListViewText$(listViewHandle(0), row, 2)
'result = EditListViewData(listViewHandle(0), row, 0, GetListViewText$(listViewHandle(0), row, 0)
result = EditListViewData(listViewHandle(0), row, 0, GetListViewText$(listViewHandle(0), row, 0) + " Edited") result = EditListViewData(listViewHandle(0), row, 1, GetListViewText$(listViewHandle(0), row, 1) + " Edited") result = EditListViewData(listViewHandle(0), row, 2, GetListViewText$(listViewHandle(0), row, 2) + " Edited")
result = SelectListViewRow(listViewHandle(0), row, True) End Sub
Sub DeleteItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) result = SendMessageLVITEMStruct(listViewHandle(0), listViewConstants.LVM.DELETEITEM.struct, row) currentRow = (currentRow - 1) End Sub
Sub InitCommonControls CallDLL #comctl32, "InitCommonControls", ret As void End Sub
Sub initializeListViewConstants 'Create the structs for ListViews
Struct LVITEM, mask As ulong, _ iItem As long, _ iSubItem As long, _ state As ulong, _ stateMask As ulong,_ pszText As ptr, _ cchTextMax As long, _ iImage As long, _ lParam As long, _ iIndent As long
Struct LVCOLUMN, mask As ulong, _ fmt As long, _ cx As long, _ pszText As ptr, _ cchTextMax As long, _ iSubItem As long, _ iImage As long, _ iOrder As long
Struct LVFINDINFO, flags As ulong, _ psz As ptr, _ lParam As ulong, _ pt As ulong, _ 'point structure vkDirection As ulong
Struct listViewConstants, LVP.DBLCLK As long, _ LVS.REPORT As long, _ LVS.SINGLESEL As long, _ LVS.SHOWSELALWAYS As long, _ LVS.NOSORTHEADER As long, _ LVS.EXDOUBLEBUFFER As long, _ LVS.EX.FULLROWSELECT As long, _ LVS.EX.CHECKBOXES As long, _ LVIS.FOCUSED As long, _ LVIS.UNSELECTED As long, _ LVIS.SELECTED As long, _ LVIS.CHECKED As long, _ LVIS.UNCHECKED As long, _ LVIS.STATEIMAGEMASK As long, _ LVIF.TEXT As long, _ LVIF.STATE As long, _ LVIR.BOUNDS As long, _ LVFI.STRING As long, _ LVFI.PARTIAL As long, _ LVN.ITEMCHANGED As long, _ LVM.ENSUREVISIBLE As long, _ LVM.SETITEMSTATE As long, _ LVM.GETITEMSTATE As long, _ LVM.GETITEMTEXT As long, _ LVM.FINDITEMA As long, _ LVM.SETITEM As long, _ LVM.GETITEMCOUNT As long, _ LVM.GETITEMA As long, _ LVM.GETSUBITEMRECT As long, _ LVM.DELETEITEM As long, _ LVM.INSERTITEM As long, _ LVM.INSERTCOLUMN As long, _ LVM.SETEXTENDEDLISTVIEWSTYLE As long, _ LVM.SETBKCOLOR As long
'LVM_FIRST = &H1000 or 4096 listViewConstants.LVP.DBLCLK.struct = False listViewConstants.LVS.REPORT.struct = 1 listViewConstants.LVS.SINGLESEL.struct = 4 listViewConstants.LVS.SHOWSELALWAYS.struct = 8 listViewConstants.LVS.NOSORTHEADER.struct = 32768 listViewConstants.LVS.EXDOUBLEBUFFER.struct = 10000 listViewConstants.LVS.EX.FULLROWSELECT.struct = 32 listViewConstants.LVS.EX.CHECKBOXES.struct = 4 listViewConstants.LVIS.FOCUSED.struct = 1 listViewConstants.LVIS.UNSELECTED.struct = 0 listViewConstants.LVIS.SELECTED.struct = 2 listViewConstants.LVIS.CHECKED.struct = 8192 listViewConstants.LVIS.UNCHECKED.struct = 4096 listViewConstants.LVIS.STATEIMAGEMASK.struct = 61440 listViewConstants.LVIF.TEXT.struct = 1 listViewConstants.LVIF.STATE.struct = 8 listViewConstants.LVIR.BOUNDS.struct = 0 listViewConstants.LVFI.STRING.struct = 2 listViewConstants.LVFI.PARTIAL.struct = 8 listViewConstants.LVN.ITEMCHANGED.struct = -101 listViewConstants.LVM.ENSUREVISIBLE.struct = 4115 listViewConstants.LVM.SETITEMSTATE.struct = 4139 listViewConstants.LVM.GETITEMSTATE.struct = 4140 listViewConstants.LVM.GETITEMTEXT.struct = 4141 listViewConstants.LVM.FINDITEMA.struct = 4109 listViewConstants.LVM.SETITEM.struct = 4102 listViewConstants.LVM.GETITEMCOUNT.struct = 4100 listViewConstants.LVM.GETITEMA.struct = 4101 listViewConstants.LVM.GETSUBITEMRECT.struct = 4152 listViewConstants.LVM.DELETEITEM.struct = 4104 listViewConstants.LVM.INSERTITEM.struct = 4103 listViewConstants.LVM.INSERTCOLUMN.struct = 4123 listViewConstants.LVM.SETEXTENDEDLISTVIEWSTYLE.struct = 4150 listViewConstants.LVM.SETBKCOLOR = 4097 'hexdec("1001") End Sub
Function CreateListView(ByRef style, ByRef styleEx, ByRef hParent, ByRef hInstance, ByRef xloc, ByRef yloc, ByRef width, ByRef height) className$ = "SysListView32" + chr$(0) CallDLL #user32, "CreateWindowExA", styleEx As ulong, _ ' extended style className$ As ptr, _ ' class name "" As ptr, _ style As ulong, _ ' style xloc As long, _ ' left x yloc As long, _ ' top y width As long, _ ' width height As long, _ ' height hParent As ulong, _ ' parent hWnd _NULL As ulong, _ hInstance As ulong, _ ' hInstance _NULL As ulong, _ CreateListView As ulong 'Hwnd to ListView
'LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT End Function
Function GetWindowLong(hWnd, index) CallDLL #user32, "GetWindowLongA", hWnd As ulong, _ index As long, _ GetWindowLong As long End Function
Function GetListViewItemCount(hWndLV) GetListViewItemCount = SendMessage(hWndLV, listViewConstants.LVM.GETITEMCOUNT.struct, 0, 0) End Function
Function createNewListColumn(hListView, columnIndex, columnWidth, headerCaption$) LVCOLUMN.cx.struct = columnWidth LVCOLUMN.pszText.struct = headerCaption$ LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT createNewListColumn = SendMessageLVCOLUMNStruct(hListView, listViewConstants.LVM.INSERTCOLUMN.struct, columnIndex) End Function
Function AddListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.INSERTITEM.struct, 0) AddListViewData = SendMessage(hWndLV, listViewConstants.LVM.GETITEMSTATE.struct, 0, 0) End Function
Function EditListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function SelectListViewRow(hWndLV, row, setFocus) LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.state.struct = listViewConstants.LVIS.SELECTED.struct If setFocus = True Then LVITEM.state.struct = (LVITEM.state.struct Or listViewConstants.LVIS.FOCUSED.struct) End If 'SelectListViewRow = SetFocus(hWndLV) SelectListViewRow = SendMessage(hWndLV, listViewConstants.LVM.ENSUREVISIBLE.struct, row, False) SelectListViewRow = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function setListViewFullRowSelect(hListView) setListViewFullRowSelect = SendMessage(hListView, 4150, 32, 32)'LVS_EX_FULLROWSELECT End Function
Function listViewShowGrid(hListView) listViewShowGrid = SendMessage(hListView, 4150, 1, 1)'LVS_EX_GRIDLINES End Function
Function SendMessage(hWnd, Msg, wParam, lParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ lParam As long, _ SendMessage As long End Function
Function SendMessageLVITEMStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVITEM As struct, _ SendMessageLVITEMStruct As long End Function
Function SendMessageLVCOLUMNStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVCOLUMN As struct, _ SendMessageLVCOLUMNStruct As long End Function
Function DestroyWindow(hWnd) CallDLL #user32, "DestroyWindow", hWnd As ulong, _ DestroyWindow As long End Function
Function GetSelectedListViewRow(hWndLV) GetSelectedListViewRow = -1
numListViewEntries = GetListViewItemCount(hWndLV) For row = 0 To (numListViewEntries - 1) LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 'first column LVITEM.stateMask.struct = listViewConstants.LVIS.SELECTED.struct result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMA.struct, 0) If LVITEM.state.struct And listViewConstants.LVIS.SELECTED.struct Then GetSelectedListViewRow = row Exit Function Else If row = (numListViewEntries - 1) Then GetSelectedListViewRow = -1 Exit Function End If End If Next row
End Function
Function GetListViewText$(hWndLV, row, column) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iSubItem.struct = column LVITEM.pszText.struct = Space$(_MAX_PATH) + chr$(0) LVITEM.cchTextMax.struct = Len(Winstring(LVITEM.pszText.struct)) EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMTEXT.struct, row) GetListViewText$ = Trim$(Winstring(LVITEM.pszText.struct)) End Function
Not quite as pretty as one would hope. Looks like text gets a different background color, as well; you're right about LVM_SETTEXTBKCOLOR. It works the same way as LVM_SETBKCOLOR, and it's value is 0x1026.
As for how to get the values, you can try googling for their C definitions if the MSDN page doesn't list their values, just google "#define <CONSTANT>", like "#define LVM_SETTEXTBKCOLOR".
As for how I got the values, I have the Windows SDK installed on my computer, which has the header files that define all of them.
From CommCtrl.h:
//====== Ranges for control message IDs =======================================
#define LVM_FIRST 0x1000 // ListView messages
And:
#define LVM_SETBKCOLOR (LVM_FIRST + 1) ... #define LVM_SETTEXTBKCOLOR (LVM_FIRST + 38)
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 15, 2020 13:35:41 GMT -5
Hmmmmm I commented out LVM.SETBKCOLOR = hexdec("1001")
As I'd added listViewConstants.LVM.SETBKCOLOR = 4097 'hexdec("1001")
To the Struct listViewConstants And I completely misread the listview handles as the same thing I shall hang my head in shame and try to attempt to change the individual row colours. Thanks for the help and pointers, I shall return soon no doubt!
|
|
|
Post by metro on Dec 15, 2020 19:23:40 GMT -5
And I completely misread the listview handles as the same thing I shall hang my head in shame and try to attempt to change the individual row colours. Thanks for the help and pointers, I shall return soon no doubt! From the date stamp on my program it looks like I played with this in 2017 not sure if is of use, gone a bit rusty have avoided a keyboard for over 6 months
global holdBgColor
Struct LVCOLUMN, _ mask As ulong, _ fmt As long, _ cx As long, _ pszText$ As ptr, _ cchTextMax As long, _ iSubItem As long, _ iImage As long, _ iOrder As long
Struct LVITEM, _ mask As ulong, _ iItem As long, _ iSubItem As long, _ state As ulong, _ stateMask As ulong, _ pszText$ As ptr, _ cchTextMax As long, _ iImage As long, _ lParam As long, _ iIndent As long
'listview constants LVS.NOSORTHEADER = 32768 : LVS.REPORT = 1 : LVS.SINGLESEL = 4 : LVS.SHOWSELALWAYS = 8 LVS.SORTASCENDING = 16 : LVS.SORTDESCENDING = 32 : LVS.NOLABELWRAP = 128 : LVS.AUTOARRANGE = 256 LVS.NOSCROLL = 8192 : LVS.ALIGNTOP = 0 : LVS.ALIGNLEFT = 2048 : LVS.NOCOLUMNHEADER = 16384 LVIF.TEXT = 1 : LVIF.STATE = 8 : LVIS.UNSELECTED = 0 : LVIS.FOCUSED = 1 LVIS.SELECTED = 2 : LVM.FIRST = 4096 : LVM.SETITEM = 4102 : LVM.INSERTITEM = 4103 LVM.INSERTCOLUMN = 4123 : LVM.GETITEMCOUNT = 4100 : LVM.GETITEMA = 4101 : LVM.GETITEMTEXTA = 4141 LVM.GETITEMSTATE = 4138 : LVM.SETITEMSTATE = 4139 : LVM.DELETEITEM = 4104 : LVM.DELETEALLITEMS = 4105 LVM.SETTEXTCOLOR = 4132 : LVM.SETBKCOLOR= 4097 : LVM.SETTEXTBKCOLOR = 4134 : LVM.DELETEALLITEMS = 4105 LVM.UPDATE = 4138 : LVIF.IMAGE = 2 : LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVS.EX.GRIDLINES= 1 : LVCFMT.CENTER = 2 : LVCFMT.RIGHT = 1 : LVCF.FMT = 1 LVS.LIST= 3 : LVS.SMALLICON= 2 : LVSCW.AUTOSIZE= -1
LVS.EX.FULLROWSELECT = hexdec("20") LVM.SETEXTENDEDLISTVIEWSTYLE = LVM.FIRST + 54
holdTxtColor=0 holdBgColor=13825525 ' holdBgColor=139119107 ' holdBgColor=4134 nomainwin WindowWidth = 390 WindowHeight = 232 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
open "untitled" for dialog as #1 print #1, "font ms_sans_serif 10" print #1, "trapclose [quit.1]"
colorOn=1 'Listview Report style =_WS_CHILD OR _WS_VISIBLE OR LVS.REPORT OR LVS.SHOWSELALWAYS OR LVS.EX.GRIDLINES hListview1 = CreateWindowEx(_WS_EX_CLIENTEDGE,"SysListView32","",style,0, 0, 380, 200,hwnd(#1),hInst)
' call sendMessage hListview1, _WM_SETFONT ,hFont ,1
if colorOn=1 then call sendMessage hListview1,LVM.SETBKCOLOR, 0,holdBgColor ' call sendMessage hListview1,LVM.SETTEXTBKCOLOR,0,413 ' call sendMessage hListview1,LVM.SETTEXTCOLOR, 0,holdTxtColor end if
if gridOn=0 then call sendMessage hListview1,LVM.SETEXTENDEDLISTVIEWSTYLE,LVS.EX.GRIDLINES,LVS.EX.GRIDLINES end if
'Set listview colum title, width, and format columnName$(1)="Nutrient" columnWidth(1)=200
columnName$(2)="Unit" columnWidth(2)=75
columnName$(3)="Amount" columnWidth(3)=100
'here LVCOLUMN.fmt.struct = 3 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT or LVCF.FMT
for x=1 to 3 if x=2 then 'Center justify 2nd column. format=LVCFMT.CENTER LVCOLUMN.fmt.struct = LVCFMT.CENTER end if
if x=3 then 'Right justify 3rd column. format=LVCFMT.RIGHT LVCOLUMN.fmt.struct = LVCFMT.RIGHT end if
LVCOLUMN.fmt.struct = format LVCOLUMN.cx.struct = columnWidth(x) LVCOLUMN.pszText$.struct =columnName$(x)
call AddColumn hListview1,x-1 next x
'fill the listview n$=chr$(0) a$(1)= "Crude Protein"; n$; "%"; n$; "20.00" a$(2)= "Crude Fat"; n$; "%"; n$; "3.50" a$(3)= "Vitamin A"; n$; "IU/lb"; n$; "4000.00" a$(4)= "Zinc"; n$; "ppm"; n$; "120.00" a$(5)= "Bronze"; n$; "ppm"; n$; "180.00"
LVITEM.mask.struct = LVIF.TEXT
for x=1 to 5
label$ = word$(a$(x),1,n$) unit$ = word$(a$(x),2,n$) amount$ = word$(a$(x),3,n$)
'1st column info. holdBgColor=139119107 ' holdBgColor=139119107 call sendMessage hListview1,LVM.SETTEXTBKCOLOR,0,holdBgColor LVITEM.iItem.struct = x-1 'row LVITEM.iSubItem.struct = 0 'column LVITEM.pszText$.struct = label$ call sendLvItemMessageStruct hListview1,LVM.INSERTITEM,0
'2nd column info.
LVITEM.iSubItem.struct = 1 LVITEM.pszText$.struct = unit$ call sendLvItemMessageStruct hListview1,LVM.SETITEM,0
'3rd column info. LVITEM.iSubItem.struct = 2 LVITEM.pszText$.struct = amount$
' if val(amount$)>2000 then
' end if
' call sendLvItemMessageStruct hListview1,LVM.SETITEM,0 next
wait
[quit.1] 'End the program close #1 END sub filBG colnum
end sub
FUNCTION CreateWindowEx(extended,class$,title$,style,left,top,width,height,hParent,pInst) calldll #user32, "CreateWindowExA",_ extended as ulong,_ class$ as ptr,_ title$ as ptr,_ style as ulong,_ left as ulong,_ top as ulong,_ width as ulong,_ height as ulong,_ hParent as ulong,_ 0 as long,_ pInst as ulong,_ 0 as long,_ CreateWindowEx as ulong END FUNCTION
FUNCTION GetWindowLong(hWnd,type) calldll #user32, "GetWindowLongA",_ hWnd as ulong,_ type as long,_ GetWindowLong as long END FUNCTION
SUB sendMessage hWnd,msg,wParam,lParam calldll #user32, "SendMessageA",_ hWnd as ulong, _ msg as long,_ wParam as long, _ lParam as long,_ r as long END SUB
'listview messages SUB AddColumn hWnd,index CallDLL #user32, "SendMessageA",_ hWnd as ulong,_ 4123 as long,_ index as long,_ LVCOLUMN as struct,_ r as long END SUB
SUB sendLvItemMessageStruct h,m,l CallDLL #user32, "SendMessageA",_ h as ulong,_ m as long,_ l as long,_ LVITEM as struct,_ r as long END SUB
Sub ListView.SetItemImage hWnd, iItem, iSubItem, iImage LVITEM.mask.struct = 2 'LVIF_IMAGE LVITEM.iItem.struct = iItem LVITEM.iSubItem.struct = iSubItem LVITEM.iImage.struct = iImage call sendLvItemMessageStruct hWnd,4102,0 End Sub
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 16, 2020 15:02:09 GMT -5
Thanks metro, sadly you code confuses me somewhat!
The concept here is to only change the colour of the listview row once the data inside has changed. I realise now, that should have been in the first post, sorry. While the code below, will change the row on start, I don't seem to be able to change it once it's added. I've tried adding the following code to both the add and edit item subs to no avail. I understand I need to send the row to it so it knows to change which one but for the life of me I'm hitting blank each time. I've tried moving this code into the AddItem sub, so that after row 4 it change the colours. It doesn't work I thought it maybe a blank var inside a sub issue, so added hListView as a GLOBAL, at which point it prints everything in white, even the grid! No different for LVM.SETBKROWCOLOR etc.
colorBG = purple colorTXT = white CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKROWCOLOR as long, 0 as long, colorBG as ulong, ret as long CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKROWTXTCOLOR as long, 0 as long, colorTXT as ulong, ret as long
So this is all I have.
'NoMainWin Global False : False = 0 Global True : True = 1 Global currentRow : currentRow = 0 GLOBAL colorBG, colorTXT GLOBAL black, white, purple
listViewHandle(0) = _NULL
'Need this to be set LVM.SETBKROWCOLOR = hexdec("1026") LVM.SETROWTXTCOLOR = hexdec("1024")
red = 128 blue = 240 green = 10
'Color calc was backwards. Byte order in a COLORREF is apparently ABGR, 'and I don't think the alpha channel is actually used.
red = 128 : blue = 240 : green = 10 purple = (blue * (256 ^ 2)) + (green * 256) + red
red = 255 : blue = 255 : green = 255 white = (blue * (256 ^ 2)) + (green * 256) + red
red = 0 : blue = 0 : green = 0 black = (blue * (256 ^ 2)) + (green * 256) + red
colorBG = white colorTXT = black
Call initializeListViewConstants
WindowWidth = 530 WindowHeight = 335 Button #Example.btnAddItem, "Add Item", AddItem, UL, 5, (WindowHeight - 65) Button #Example.btnEditItem, "Edit Item", EditItem, UL, 202.5, (WindowHeight - 65) Button #Example.btnDeleteItem, "Delete Item", DeleteItem, UL, 405, (WindowHeight - 65)
Open "ListView Example" For Window As #Example Call InitCommonControls style = _WS_CHILD Or _WS_VISIBLE Or listViewConstants.LVS.NOSORTHEADER.struct _ Or listViewConstants.LVS.REPORT.struct Or listViewConstants.LVS.SHOWSELALWAYS.struct _ Or listViewConstants.LVS.SINGLESEL.struct styleEx = _WS_EX_CLIENTEDGE Or _WS_EX_DLGMODALFRAME 'Or listViewConstants.LVS.EX.DOUBLEBUFFER.struct listViewHandle(0) = CreateListView(style, styleEx, Hwnd(#Example), GetWindowLong(Hwnd(#Example), _GWL_HINSTANCE), 5, 23, 505, 244) result = setListViewFullRowSelect(listViewHandle(0)) result = listViewShowGrid(listViewHandle(0)) result = createNewListColumn(listViewHandle(0), 0, 100, " Item 1") result = createNewListColumn(listViewHandle(0), 1, 100, " Item 2") result = createNewListColumn(listViewHandle(0), 2, 100, " Item 3") #Example "TrapClose Quit"
hListView = listViewHandle(0)
'change background colour, then request its done. 'colorBG = purple 'colorTXT = white 'CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKROWCOLOR as long, 0 as long, colorBG as ulong, ret as long 'CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETROWTXTCOLOR as long, 0 as long, colorTXT as ulong, ret as long
WAIT
Sub Quit handle$ result = DestroyWindow(listViewHandle(0)) Close #handle$ End End Sub
Sub AddItem handle$
IF currentRow > 3 THEN hListView = listViewHandle(0) 'just trying things colorBG = purple : colorTXT = white print currentRow, purple, white CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKROWCOLOR as long, 0 as long, colorBG as ulong, ret as long CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKROWTXTCOLOR as long, 0 as long, colorTXT as ulong, ret as long END IF
result = AddListViewData(listViewHandle(0), currentRow, 0, "Data1") result = EditListViewData(listViewHandle(0), currentRow, 1, "Data2") result = EditListViewData(listViewHandle(0), currentRow, 2, "Data3") result = SelectListViewRow(listViewHandle(0), currentRow, True) currentRow = (currentRow + 1) End Sub
Sub EditItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) item1$ = GetListViewText$(listViewHandle(0), row, 0) item2$ = GetListViewText$(listViewHandle(0), row, 1) item3$ = GetListViewText$(listViewHandle(0), row, 2)
'result = GetSelectedListViewRow(listViewHandle(0))
result = EditListViewData(listViewHandle(0), row, 0, GetListViewText$(listViewHandle(0), row, 0) + " Edited") result = EditListViewData(listViewHandle(0), row, 1, GetListViewText$(listViewHandle(0), row, 1) + " Edited") result = EditListViewData(listViewHandle(0), row, 2, GetListViewText$(listViewHandle(0), row, 2) + " Edited")
result = SelectListViewRow(listViewHandle(0), row, True) End Sub
Sub DeleteItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) result = SendMessageLVITEMStruct(listViewHandle(0), listViewConstants.LVM.DELETEITEM.struct, row) currentRow = (currentRow - 1) End Sub
Sub InitCommonControls CallDLL #comctl32, "InitCommonControls", ret As void End Sub
Sub initializeListViewConstants 'Create the structs for ListViews
Struct LVITEM, mask As ulong, _ iItem As long, _ iSubItem As long, _ state As ulong, _ stateMask As ulong,_ pszText As ptr, _ cchTextMax As long, _ iImage As long, _ lParam As long, _ iIndent As long
Struct LVCOLUMN, mask As ulong, _ fmt As long, _ cx As long, _ pszText As ptr, _ cchTextMax As long, _ iSubItem As long, _ iImage As long, _ iOrder As long
Struct LVFINDINFO, flags As ulong, _ psz As ptr, _ lParam As ulong, _ pt As ulong, _ 'point structure vkDirection As ulong
Struct listViewConstants, LVP.DBLCLK As long, _ LVS.REPORT As long, _ LVS.SINGLESEL As long, _ LVS.SHOWSELALWAYS As long, _ LVS.NOSORTHEADER As long, _ LVS.EXDOUBLEBUFFER As long, _ LVS.EX.FULLROWSELECT As long, _ LVS.EX.CHECKBOXES As long, _ LVIS.FOCUSED As long, _ LVIS.UNSELECTED As long, _ LVIS.SELECTED As long, _ LVIS.CHECKED As long, _ LVIS.UNCHECKED As long, _ LVIS.STATEIMAGEMASK As long, _ LVIF.TEXT As long, _ LVIF.STATE As long, _ LVIR.BOUNDS As long, _ LVFI.STRING As long, _ LVFI.PARTIAL As long, _ LVN.ITEMCHANGED As long, _ LVM.ENSUREVISIBLE As long, _ LVM.SETITEMSTATE As long, _ LVM.GETITEMSTATE As long, _ LVM.GETITEMTEXT As long, _ LVM.FINDITEMA As long, _ LVM.SETITEM As long, _ LVM.GETITEMCOUNT As long, _ LVM.GETITEMA As long, _ LVM.GETSUBITEMRECT As long, _ LVM.DELETEITEM As long, _ LVM.INSERTITEM As long, _ LVM.INSERTCOLUMN As long, _ LVM.SETEXTENDEDLISTVIEWSTYLE As long 'LVM.SETBKROWCOLOR As long
'LVM_FIRST = &H1000 or 4096 listViewConstants.LVP.DBLCLK.struct = False listViewConstants.LVS.REPORT.struct = 1 listViewConstants.LVS.SINGLESEL.struct = 4 listViewConstants.LVS.SHOWSELALWAYS.struct = 8 listViewConstants.LVS.NOSORTHEADER.struct = 32768 listViewConstants.LVS.EXDOUBLEBUFFER.struct = 10000 listViewConstants.LVS.EX.FULLROWSELECT.struct = 32 listViewConstants.LVS.EX.CHECKBOXES.struct = 4 listViewConstants.LVIS.FOCUSED.struct = 1 listViewConstants.LVIS.UNSELECTED.struct = 0 listViewConstants.LVIS.SELECTED.struct = 2 listViewConstants.LVIS.CHECKED.struct = 8192 listViewConstants.LVIS.UNCHECKED.struct = 4096 listViewConstants.LVIS.STATEIMAGEMASK.struct = 61440 listViewConstants.LVIF.TEXT.struct = 1 listViewConstants.LVIF.STATE.struct = 8 listViewConstants.LVIR.BOUNDS.struct = 0 listViewConstants.LVFI.STRING.struct = 2 listViewConstants.LVFI.PARTIAL.struct = 8 listViewConstants.LVN.ITEMCHANGED.struct = -101 listViewConstants.LVM.ENSUREVISIBLE.struct = 4115 listViewConstants.LVM.SETITEMSTATE.struct = 4139 listViewConstants.LVM.GETITEMSTATE.struct = 4140 listViewConstants.LVM.GETITEMTEXT.struct = 4141 listViewConstants.LVM.FINDITEMA.struct = 4109 listViewConstants.LVM.SETITEM.struct = 4102 listViewConstants.LVM.GETITEMCOUNT.struct = 4100 listViewConstants.LVM.GETITEMA.struct = 4101 listViewConstants.LVM.GETSUBITEMRECT.struct = 4152 listViewConstants.LVM.DELETEITEM.struct = 4104 listViewConstants.LVM.INSERTITEM.struct = 4103 listViewConstants.LVM.INSERTCOLUMN.struct = 4123 listViewConstants.LVM.SETEXTENDEDLISTVIEWSTYLE.struct = 4150 'listViewConstants.LVM.SETBKROWCOLOR = 4097 'hexdec("1001") End Sub
Function CreateListView(ByRef style, ByRef styleEx, ByRef hParent, ByRef hInstance, ByRef xloc, ByRef yloc, ByRef width, ByRef height) className$ = "SysListView32" + chr$(0) CallDLL #user32, "CreateWindowExA", styleEx As ulong, _ ' extended style className$ As ptr, _ ' class name "" As ptr, _ style As ulong, _ ' style xloc As long, _ ' left x yloc As long, _ ' top y width As long, _ ' width height As long, _ ' height hParent As ulong, _ ' parent hWnd _NULL As ulong, _ hInstance As ulong, _ ' hInstance _NULL As ulong, _ CreateListView As ulong 'Hwnd to ListView
'LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT End Function
Function GetWindowLong(hWnd, index) CallDLL #user32, "GetWindowLongA", hWnd As ulong, _ index As long, _ GetWindowLong As long End Function
Function GetListViewItemCount(hWndLV) GetListViewItemCount = SendMessage(hWndLV, listViewConstants.LVM.GETITEMCOUNT.struct, 0, 0) End Function
Function createNewListColumn(hListView, columnIndex, columnWidth, headerCaption$) LVCOLUMN.cx.struct = columnWidth LVCOLUMN.pszText.struct = headerCaption$ LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT createNewListColumn = SendMessageLVCOLUMNStruct(hListView, listViewConstants.LVM.INSERTCOLUMN.struct, columnIndex) End Function
Function AddListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.INSERTITEM.struct, 0) AddListViewData = SendMessage(hWndLV, listViewConstants.LVM.GETITEMSTATE.struct, 0, 0) End Function
Function EditListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function SelectListViewRow(hWndLV, row, setFocus) LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.state.struct = listViewConstants.LVIS.SELECTED.struct If setFocus = True Then LVITEM.state.struct = (LVITEM.state.struct Or listViewConstants.LVIS.FOCUSED.struct) End If 'SelectListViewRow = SetFocus(hWndLV) SelectListViewRow = SendMessage(hWndLV, listViewConstants.LVM.ENSUREVISIBLE.struct, row, False) SelectListViewRow = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function setListViewFullRowSelect(hListView) setListViewFullRowSelect = SendMessage(hListView, 4150, 32, 32)'LVS_EX_FULLROWSELECT End Function
Function listViewShowGrid(hListView) listViewShowGrid = SendMessage(hListView, 4150, 1, 1)'LVS_EX_GRIDLINES End Function
Function SendMessage(hWnd, Msg, wParam, lParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ lParam As long, _ SendMessage As long End Function
Function SendMessageLVITEMStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVITEM As struct, _ SendMessageLVITEMStruct As long End Function
Function SendMessageLVCOLUMNStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVCOLUMN As struct, _ SendMessageLVCOLUMNStruct As long End Function
Function DestroyWindow(hWnd) CallDLL #user32, "DestroyWindow", hWnd As ulong, _ DestroyWindow As long End Function
Function GetSelectedListViewRow(hWndLV) GetSelectedListViewRow = -1
numListViewEntries = GetListViewItemCount(hWndLV) For row = 0 To (numListViewEntries - 1) LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 'first column LVITEM.stateMask.struct = listViewConstants.LVIS.SELECTED.struct result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMA.struct, 0) If LVITEM.state.struct And listViewConstants.LVIS.SELECTED.struct Then GetSelectedListViewRow = row Exit Function Else If row = (numListViewEntries - 1) Then GetSelectedListViewRow = -1 Exit Function End If End If Next row
End Function
Function GetListViewText$(hWndLV, row, column) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iSubItem.struct = column LVITEM.pszText.struct = Space$(_MAX_PATH) + chr$(0) LVITEM.cchTextMax.struct = Len(Winstring(LVITEM.pszText.struct)) EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMTEXT.struct, row) GetListViewText$ = Trim$(Winstring(LVITEM.pszText.struct)) End Function
|
|
|
Post by Chris Iverson on Dec 16, 2020 16:05:48 GMT -5
Two things: You need to make the LVM constants global, and you need to use the right ones.
You define the text color one as LVM.SETROWTXTCOLOR, but use it as LVM.SETBKROWTXTCOLOR in the AddItem sub.
Fix those, and you get the color change, but it won't be quite what you want.
That won't actually work the way you want it to.
You want to be able to change the color of each row individually; those messages as they're being used aren't designed for that. They change the color for the whole control.
Technically, the names "LVM.SETBKROWCOLOR" and "LVM.SETROWTXTCOLOR" are false. The actual names are LVM.SETTEXTBKCOLOR and LVM.SETTEXTCOLOR. "ROW" isn't part of the name, because it doesn't set the colors for just a row. LVM_SETTEXTCOLOR will set the color of ALL text on the control, and LVM_SETTEXTBKCOLOR will set the color of what that text is laid against, over all of the control.
Now, if you actually make those changes I suggested, and press the "Add Item" button more than four times, it will actually look like it worked! The first four will have a white background, and the next four will have a purple background.
However, this is NOT permanent, and is a result of Windows defaulting to lazy updates: if something hasn't been explicitly changed, it doesn't get redrawn. If you cover/minimize the window, and bring it back up, Windows will have to redraw the whole window, and when it does, ALL of the rows will have purple as their background.
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 17, 2020 12:41:12 GMT -5
Thanks Chris, I did try them as GLOBALS but obviously having a typo in the names was throwing everything off.
I added the word ROW to try to simplify things in my mind that's all, as I assume LB doesn't really care what the names actually are, but humans do! Unless that human is trying to search for the resource on MSDN :/
I'm unable to find any reference to actually change the row colours, or "flush". Since the idea was to change the row colour on the fly as such the above method wont work unless I redraw the entire listview.
I've seen this work in other programs tho (not created in LB) so it must be possible. Perhaps not easily enough for me to comprehend.
|
|
|
Post by Chris Iverson on Dec 17, 2020 13:20:15 GMT -5
It can be done, but not directly in LB. Essentially, you have to intercept message handling on the ListView, and switch the colors while letting the system draw each row. I don't think this can even be done with WMLiberty's help, since it requires taking action after default processing has occurred, and I don't think WMLiberty will let you do that. Here's an annotated C++ example that I'm drawing this information from: www.codeproject.com/articles/20796/listview-alternating-row-colours-using-windows-api
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 18, 2020 6:31:49 GMT -5
Thanks Chris, I did come across that page already, but the way I read that article was it looped thru and redrew all the info, with my listview having potentially 10,000 items by the end of the day redrawing will take too long, especially if I have more info coming in at the same time. Then I'd need to add buffers etc. Colour coding rows would be an excellent addition but too much for me. It's all too complex for me.
It also helps when searching for this, I changed from colour to color, which actually gave more and better results. But effectively they all seem to be around reloading the listview.
For others needing some form of this in future, here is "working" code to change background and text colours within a listview.
'NoMainWin Global False : False = 0 Global True : True = 1 Global currentRow : currentRow = 0 GLOBAL colorBG, colorTXT GLOBAL black, white, purple GLOBAL LVM.SETBKROWCOLOR, LVM.SETROWTXTCOLOR
listViewHandle(0) = _NULL
'Need this to be set LVM.SETBKROWCOLOR = hexdec("1026") LVM.SETROWTXTCOLOR = hexdec("1024")
red = 128 blue = 240 green = 10
'Color calc was backwards. Byte order in a COLORREF is apparently ABGR, 'and I don't think the alpha channel is actually used.
red = 128 : blue = 240 : green = 10 purple = (blue * (256 ^ 2)) + (green * 256) + red
red = 255 : blue = 255 : green = 255 white = (blue * (256 ^ 2)) + (green * 256) + red
red = 0 : blue = 0 : green = 0 black = (blue * (256 ^ 2)) + (green * 256) + red
colorBG = white colorTXT = black
Call initializeListViewConstants
WindowWidth = 530 WindowHeight = 335 Button #Example.btnAddItem, "Add Item", AddItem, UL, 5, (WindowHeight - 65) Button #Example.btnEditItem, "Edit Item", EditItem, UL, 202.5, (WindowHeight - 65) Button #Example.btnDeleteItem, "Delete Item", DeleteItem, UL, 405, (WindowHeight - 65)
Open "ListView Example" For Window As #Example Call InitCommonControls style = _WS_CHILD Or _WS_VISIBLE Or listViewConstants.LVS.NOSORTHEADER.struct _ Or listViewConstants.LVS.REPORT.struct Or listViewConstants.LVS.SHOWSELALWAYS.struct _ Or listViewConstants.LVS.SINGLESEL.struct styleEx = _WS_EX_CLIENTEDGE Or _WS_EX_DLGMODALFRAME 'Or listViewConstants.LVS.EX.DOUBLEBUFFER.struct listViewHandle(0) = CreateListView(style, styleEx, Hwnd(#Example), GetWindowLong(Hwnd(#Example), _GWL_HINSTANCE), 5, 23, 505, 244) result = setListViewFullRowSelect(listViewHandle(0)) result = listViewShowGrid(listViewHandle(0)) result = createNewListColumn(listViewHandle(0), 0, 100, " Item 1") result = createNewListColumn(listViewHandle(0), 1, 100, " Item 2") result = createNewListColumn(listViewHandle(0), 2, 100, " Item 3") #Example "TrapClose Quit"
hListView = listViewHandle(0)
'change background colour, then request its done. 'colorBG = purple 'colorTXT = white 'CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKROWCOLOR as long, 0 as long, colorBG as ulong, ret as long 'CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETROWTXTCOLOR as long, 0 as long, colorTXT as ulong, ret as long
WAIT
Sub Quit handle$ result = DestroyWindow(listViewHandle(0)) Close #handle$ End End Sub
Sub AddItem handle$
IF currentRow > 3 THEN hListView = listViewHandle(0) 'just trying things colorBG = purple : colorTXT = white print currentRow, purple, white CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETBKROWCOLOR as long, 0 as long, colorBG as ulong, ret as long CallDLL #user32, "SendMessageA", hListView as ulong, LVM.SETROWTXTCOLOR as long, 0 as long, colorTXT as ulong, ret as long END IF
result = AddListViewData(listViewHandle(0), currentRow, 0, "Data1") result = EditListViewData(listViewHandle(0), currentRow, 1, "Data2") result = EditListViewData(listViewHandle(0), currentRow, 2, "Data3") result = SelectListViewRow(listViewHandle(0), currentRow, True) currentRow = (currentRow + 1) End Sub
Sub EditItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) item1$ = GetListViewText$(listViewHandle(0), row, 0) item2$ = GetListViewText$(listViewHandle(0), row, 1) item3$ = GetListViewText$(listViewHandle(0), row, 2)
'result = GetSelectedListViewRow(listViewHandle(0))
result = EditListViewData(listViewHandle(0), row, 0, GetListViewText$(listViewHandle(0), row, 0) + " Edited") result = EditListViewData(listViewHandle(0), row, 1, GetListViewText$(listViewHandle(0), row, 1) + " Edited") result = EditListViewData(listViewHandle(0), row, 2, GetListViewText$(listViewHandle(0), row, 2) + " Edited")
result = SelectListViewRow(listViewHandle(0), row, True) End Sub
Sub DeleteItem handle$ numListViewEntries = GetListViewItemCount(listViewHandle(0)) If Not(numListViewEntries) Then Exit Sub row = GetSelectedListViewRow(listViewHandle(0)) result = SendMessageLVITEMStruct(listViewHandle(0), listViewConstants.LVM.DELETEITEM.struct, row) currentRow = (currentRow - 1) End Sub
Sub InitCommonControls CallDLL #comctl32, "InitCommonControls", ret As void End Sub
Sub initializeListViewConstants 'Create the structs for ListViews
Struct LVITEM, mask As ulong, _ iItem As long, _ iSubItem As long, _ state As ulong, _ stateMask As ulong,_ pszText As ptr, _ cchTextMax As long, _ iImage As long, _ lParam As long, _ iIndent As long
Struct LVCOLUMN, mask As ulong, _ fmt As long, _ cx As long, _ pszText As ptr, _ cchTextMax As long, _ iSubItem As long, _ iImage As long, _ iOrder As long
Struct LVFINDINFO, flags As ulong, _ psz As ptr, _ lParam As ulong, _ pt As ulong, _ 'point structure vkDirection As ulong
Struct listViewConstants, LVP.DBLCLK As long, _ LVS.REPORT As long, _ LVS.SINGLESEL As long, _ LVS.SHOWSELALWAYS As long, _ LVS.NOSORTHEADER As long, _ LVS.EXDOUBLEBUFFER As long, _ LVS.EX.FULLROWSELECT As long, _ LVS.EX.CHECKBOXES As long, _ LVIS.FOCUSED As long, _ LVIS.UNSELECTED As long, _ LVIS.SELECTED As long, _ LVIS.CHECKED As long, _ LVIS.UNCHECKED As long, _ LVIS.STATEIMAGEMASK As long, _ LVIF.TEXT As long, _ LVIF.STATE As long, _ LVIR.BOUNDS As long, _ LVFI.STRING As long, _ LVFI.PARTIAL As long, _ LVN.ITEMCHANGED As long, _ LVM.ENSUREVISIBLE As long, _ LVM.SETITEMSTATE As long, _ LVM.GETITEMSTATE As long, _ LVM.GETITEMTEXT As long, _ LVM.FINDITEMA As long, _ LVM.SETITEM As long, _ LVM.GETITEMCOUNT As long, _ LVM.GETITEMA As long, _ LVM.GETSUBITEMRECT As long, _ LVM.DELETEITEM As long, _ LVM.INSERTITEM As long, _ LVM.INSERTCOLUMN As long, _ LVM.SETEXTENDEDLISTVIEWSTYLE As long 'LVM.SETBKROWCOLOR As long
'LVM_FIRST = &H1000 or 4096 listViewConstants.LVP.DBLCLK.struct = False listViewConstants.LVS.REPORT.struct = 1 listViewConstants.LVS.SINGLESEL.struct = 4 listViewConstants.LVS.SHOWSELALWAYS.struct = 8 listViewConstants.LVS.NOSORTHEADER.struct = 32768 listViewConstants.LVS.EXDOUBLEBUFFER.struct = 10000 listViewConstants.LVS.EX.FULLROWSELECT.struct = 32 listViewConstants.LVS.EX.CHECKBOXES.struct = 4 listViewConstants.LVIS.FOCUSED.struct = 1 listViewConstants.LVIS.UNSELECTED.struct = 0 listViewConstants.LVIS.SELECTED.struct = 2 listViewConstants.LVIS.CHECKED.struct = 8192 listViewConstants.LVIS.UNCHECKED.struct = 4096 listViewConstants.LVIS.STATEIMAGEMASK.struct = 61440 listViewConstants.LVIF.TEXT.struct = 1 listViewConstants.LVIF.STATE.struct = 8 listViewConstants.LVIR.BOUNDS.struct = 0 listViewConstants.LVFI.STRING.struct = 2 listViewConstants.LVFI.PARTIAL.struct = 8 listViewConstants.LVN.ITEMCHANGED.struct = -101 listViewConstants.LVM.ENSUREVISIBLE.struct = 4115 listViewConstants.LVM.SETITEMSTATE.struct = 4139 listViewConstants.LVM.GETITEMSTATE.struct = 4140 listViewConstants.LVM.GETITEMTEXT.struct = 4141 listViewConstants.LVM.FINDITEMA.struct = 4109 listViewConstants.LVM.SETITEM.struct = 4102 listViewConstants.LVM.GETITEMCOUNT.struct = 4100 listViewConstants.LVM.GETITEMA.struct = 4101 listViewConstants.LVM.GETSUBITEMRECT.struct = 4152 listViewConstants.LVM.DELETEITEM.struct = 4104 listViewConstants.LVM.INSERTITEM.struct = 4103 listViewConstants.LVM.INSERTCOLUMN.struct = 4123 listViewConstants.LVM.SETEXTENDEDLISTVIEWSTYLE.struct = 4150 'listViewConstants.LVM.SETBKROWCOLOR = 4097 'hexdec("1001") End Sub
Function CreateListView(ByRef style, ByRef styleEx, ByRef hParent, ByRef hInstance, ByRef xloc, ByRef yloc, ByRef width, ByRef height) className$ = "SysListView32" + chr$(0) CallDLL #user32, "CreateWindowExA", styleEx As ulong, _ ' extended style className$ As ptr, _ ' class name "" As ptr, _ style As ulong, _ ' style xloc As long, _ ' left x yloc As long, _ ' top y width As long, _ ' width height As long, _ ' height hParent As ulong, _ ' parent hWnd _NULL As ulong, _ hInstance As ulong, _ ' hInstance _NULL As ulong, _ CreateListView As ulong 'Hwnd to ListView
'LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT End Function
Function GetWindowLong(hWnd, index) CallDLL #user32, "GetWindowLongA", hWnd As ulong, _ index As long, _ GetWindowLong As long End Function
Function GetListViewItemCount(hWndLV) GetListViewItemCount = SendMessage(hWndLV, listViewConstants.LVM.GETITEMCOUNT.struct, 0, 0) End Function
Function createNewListColumn(hListView, columnIndex, columnWidth, headerCaption$) LVCOLUMN.cx.struct = columnWidth LVCOLUMN.pszText.struct = headerCaption$ LVCF.WIDTH = 2 : LVCF.TEXT = 4 LVCOLUMN.mask.struct = LVCF.WIDTH OR LVCF.TEXT createNewListColumn = SendMessageLVCOLUMNStruct(hListView, listViewConstants.LVM.INSERTCOLUMN.struct, columnIndex) End Function
Function AddListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.INSERTITEM.struct, 0) AddListViewData = SendMessage(hWndLV, listViewConstants.LVM.GETITEMSTATE.struct, 0, 0) End Function
Function EditListViewData(hWndLV, row, column, myData$) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = column LVITEM.pszText.struct = myData$ EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function SelectListViewRow(hWndLV, row, setFocus) LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.state.struct = listViewConstants.LVIS.SELECTED.struct If setFocus = True Then LVITEM.state.struct = (LVITEM.state.struct Or listViewConstants.LVIS.FOCUSED.struct) End If 'SelectListViewRow = SetFocus(hWndLV) SelectListViewRow = SendMessage(hWndLV, listViewConstants.LVM.ENSUREVISIBLE.struct, row, False) SelectListViewRow = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.SETITEM.struct, 0) End Function
Function setListViewFullRowSelect(hListView) setListViewFullRowSelect = SendMessage(hListView, 4150, 32, 32)'LVS_EX_FULLROWSELECT End Function
Function listViewShowGrid(hListView) listViewShowGrid = SendMessage(hListView, 4150, 1, 1)'LVS_EX_GRIDLINES End Function
Function SendMessage(hWnd, Msg, wParam, lParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ lParam As long, _ SendMessage As long End Function
Function SendMessageLVITEMStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVITEM As struct, _ SendMessageLVITEMStruct As long End Function
Function SendMessageLVCOLUMNStruct(hWnd, Msg, wParam) CallDLL #user32, "SendMessageA" , hWnd As ulong, _ Msg As long, _ wParam As long, _ LVCOLUMN As struct, _ SendMessageLVCOLUMNStruct As long End Function
Function DestroyWindow(hWnd) CallDLL #user32, "DestroyWindow", hWnd As ulong, _ DestroyWindow As long End Function
Function GetSelectedListViewRow(hWndLV) GetSelectedListViewRow = -1
numListViewEntries = GetListViewItemCount(hWndLV) For row = 0 To (numListViewEntries - 1) LVITEM.mask.struct = listViewConstants.LVIF.STATE.struct LVITEM.iItem.struct = row LVITEM.iSubItem.struct = 0 'first column LVITEM.stateMask.struct = listViewConstants.LVIS.SELECTED.struct result = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMA.struct, 0) If LVITEM.state.struct And listViewConstants.LVIS.SELECTED.struct Then GetSelectedListViewRow = row Exit Function Else If row = (numListViewEntries - 1) Then GetSelectedListViewRow = -1 Exit Function End If End If Next row
End Function
Function GetListViewText$(hWndLV, row, column) LVITEM.mask.struct = listViewConstants.LVIF.TEXT.struct LVITEM.iSubItem.struct = column LVITEM.pszText.struct = Space$(_MAX_PATH) + chr$(0) LVITEM.cchTextMax.struct = Len(Winstring(LVITEM.pszText.struct)) EditListViewData = SendMessageLVITEMStruct(hWndLV, listViewConstants.LVM.GETITEMTEXT.struct, row) GetListViewText$ = Trim$(Winstring(LVITEM.pszText.struct)) End Function
|
|
|
Post by pierre on Dec 21, 2020 13:35:40 GMT -5
|
|
Tasp
Full Member
Posts: 215
|
Post by Tasp on Dec 23, 2020 16:44:39 GMT -5
Thanks for the heads up, however this is for a LISTBOX rather than LISTVIEW, so would mean changing a lot of code for me. Could be useful for others starting out though. Perhaps if I'd found this from the start I probably would have gone down this route. However I'm too far past to start rewriting the LISTVIEW element.
May decide to change this in the future for V2.0!! But I'm closeish to a release so now isn't the time with 9+ months of dev I really want to get this to RC stage.
|
|
|
Post by nsbrown on Apr 1, 2022 11:55:02 GMT -5
any new with this topic? can LB can make a listview api with deferent row colors?
|
|
|
Post by Walt Decker on Apr 2, 2022 9:58:38 GMT -5
any new with this topic? can LB can make a listview api with deferent row colors? No. That will have to be done through a DLL.
|
|