Sign in to follow this  
Followers 0
shEiD

[SOLVED] ListView border: disable or change color

7 posts in this topic

#1 ·  Posted (edited)

Hi,

I would like to create a listview with no border, no column headers and custom color. I've tried creating a listview control in two different ways, but couldn't get the wanted result :)

Help please.

; My example Gui

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>

Global Const $COLOR_GUI = 0x494E49
Global Const $COLOR_TEXT = 0xE6ECE0

$GUI = GUICreate('test', 300, 500, -1, -1)
GUISetBkColor($COLOR_GUI)

; ======================= ListView 1
; everything works, except:
; how can I remove the border (or change it's color)

$listview = GUICtrlCreateListView("col1|col2|col3", 10, 10, 280, 200, $LVS_NOCOLUMNHEADER)
GUICtrlSetBkColor(-1, $COLOR_GUI)
GUICtrlSetColor(-1, $COLOR_TEXT)
$item1 = GUICtrlCreateListViewItem("test|col22|col23", $listview)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
_GUICtrlListView_SetColumnWidth($listview, 0, 100)
_GUICtrlListView_SetColumnWidth($listview, 1, 100)
_GUICtrlListView_SetOutlineColor($listview, $COLOR_GUI)

; ======================= ListView 2
; cool, does not have a border, but:

$hListView = _GUICtrlListView_Create($GUI, "col1|col2|col3", 10, 220, 280, 200, $LVS_NOCOLUMNHEADER)
_GUICtrlListView_SetBkColor($hListView, $COLOR_GUI)
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1, 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) ; <--------------------- Does NOT work!
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2) ; <------------ Does NOT work!
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) ; <--------------------- Does NOT work!
_GUICtrlListView_SetColumnWidth($hListView, 0, 250) ; <------------------------- Does NOT work!


GUISetState(@SW_SHOW)

While 1
    $eMSG = GUIGetMsg()
    Switch $eMSG
        Case -3
            Exit
    EndSwitch
WEnd

Gui screenshot:

Posted Image

Edited by shEiD

Share this post


Link to post
Share on other sites



shEiD,

I can do it for the UDF ListView but not for the native one: :)

; My example Gui

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <GuiListView.au3>

Global Const $COLOR_GUI = 0x494E49
Global Const $COLOR_TEXT = 0xE6ECE0

$GUI = GUICreate('test', 300, 500, -1, -1)
GUISetBkColor($COLOR_GUI)

; ======================= ListView 1
; everything works, except:
; how can I remove the border (or change it's color)

$listview = GUICtrlCreateListView("col1|col2|col3", 10, 10, 280, 200, $LVS_NOCOLUMNHEADER)
GUICtrlSetBkColor(-1, $COLOR_GUI)
GUICtrlSetColor(-1, $COLOR_TEXT)
$item1 = GUICtrlCreateListViewItem("test|col22|col23", $listview)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview)
_GUICtrlListView_SetColumnWidth($listview, 0, 90)
_GUICtrlListView_SetColumnWidth($listview, 1, 90)

; ======================= ListView 2
; You needed to add a few styles <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$hListView = _GUICtrlListView_Create($GUI, "", 10, 220, 280, 200, BitOr($LVS_REPORT,$LVS_NOCOLUMNHEADER))
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetBkColor($hListView, $COLOR_GUI)
_GUICtrlListView_SetTextBkColor($hListView, $COLOR_GUI)
_GUICtrlListView_SetTextColor($hListView, $COLOR_TEXT)

_GUICtrlListView_AddColumn($hListView, "Col 1", 90)
_GUICtrlListView_AddColumn($hListView, "Col 2", 90)
_GUICtrlListView_AddColumn($hListView, "Col 3", 90)

_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1, 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)

GUISetState(@SW_SHOW)

While 1
    $eMSG = GUIGetMsg()
    Switch $eMSG
        Case -3
            Exit
    EndSwitch
WEnd

I will keep thinking about the native one. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

shEiD,

I can do it for the UDF ListView but not for the native one: :D

I will keep thinking about the native one. :P

M23

:)

Thank YOU. I've spent hours on this trying this and that, searching the forums and chm, nothing worked. Just out of curiosity, did I miss this solution in the help.chm? I mean I still don't get it, which style fixed the problem with the rows not showing. :)

Oh, and 1 more thing I forgot before: is there a way to change "selection" color? I mean, the default blue color does not look good with this gui color...

Edited by shEiD

Share this post


Link to post
Share on other sites

shEiD,

You needed to add the $LVS_REPORT style and create the columns using _GUICtrlListView_AddColumn. :)

As to the selected colour, that is a system colour that I imagine you can change in Control Panel - but it will then apply to the whole system, which may not be what you want. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@Melba23 Thanks again for the answers and help.

If you think of way to achieve this via native listview, please lemme know.

Marking topic as solved.

Share this post


Link to post
Share on other sites

The default native listview extended styles are $WS_EX_CLIENTEDGE and $WS_EX_TRANSPARENT,

as reported by Winspector Spy.

Removing the $WS_EX_CLIENTEDGE style to eliminate the border.

$listview = GUICtrlCreateListView("col1|col2|col3", 10, 10, 280, 200, _
BitOR($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER), $WS_EX_TRANSPARENT)

I see fascists...

Share this post


Link to post
Share on other sites

rover,

Hi! :)

I could have sworn I had tried that - but obviously not. Thanks as always. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0