Page 1 of 1

Alternative to the missing #PB_ListIcon_GridLines

Posted: Thu Feb 03, 2011 8:42 pm
by Shardik
The PureBasic help for the ListIconGadget states that the flag #PB_ListIcon_GridLines
is not supported in MacOS. But the underlying DataBrowser API of MacOS has two
features which do something similar:
- one feature enables alternating row colors to optically separate the single rows
- another feature draws column dividers

This code example demonstrates their use to "simulate" grid lines:

Code: Select all

ImportC ""
  DataBrowserChangeAttributes(ControlRef.L, AttributesToSet.L, AttributesToClear.L)
EndImport

#kDataBrowserAttributeListViewAlternatingRowColors = (1 << 1)
#kDataBrowserAttributeListViewDrawColumnDividers = (1 << 2)

OpenWindow(0, 0, 0, 430, 105, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 420, 95, "Name", 110)

DataBrowserChangeAttributes(GadgetID(0), #kDataBrowserAttributeListViewAlternatingRowColors | #kDataBrowserAttributeListViewDrawColumnDividers, 0)

AddGadgetColumn(0, 1, "Address", 289)
AddGadgetItem(0, -1, "Harry Rannit" + #LF$ + "12 Parliament Way, Battle Street, By the Bay")
AddGadgetItem(0, -1, "Ginger Brokeit" + #LF$ + "130 PureBasic Road, BigTown, CodeCity")
AddGadgetItem(0, -1, "Didi Foundit"+ #LF$ + "321 Logo Drive, Mouse House, Downtown")

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow

Re: Alternative to the missing #PB_ListIcon_GridLines

Posted: Thu Feb 03, 2011 9:05 pm
by Vitor_BossĀ®
This is a VB6 version:

Code: Select all

Public Const LVM_FIRST As Long = &H1000
Public Const LVS_EX_FULLROWSELECT As Long = &H20
Public Const LVS_EX_GRIDLINES As Long = &H1
Public Const LVM_GETEXTENDEDLISTVIEWSTYLE As Long = LVM_FIRST + &H37
Public Const LVM_SETEXTENDEDLISTVIEWSTYLE As Long = LVM_FIRST + &H36

Public Sub LVstyles(Lv As Object)
    Dim lstyle As Long
    lstyle = SendMessage(Lv.hWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
    lstyle = lstyle Or LVS_EX_FULLROWSELECT Or LVS_EX_GRIDLINES
    Call SendMessage(Lv.hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ByVal lstyle)
End Sub
Hope helpful.