Sign in to follow this  
Followers 0
SandelPerieanu

$GUI_BKCOLOR_LV_ALTERNATE

8 posts in this topic

i don't know how use $GUI_BKCOLOR_LV_ALTERNATE.

please help me to understand this special flag.

Share this post


Link to post
Share on other sites



It is used in list views for colouring alternative lines differently.

From the help file

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.

The odd lines will get the color set by GUICtrlSetBkColor of the Listview control.

The even lines will get the color set by GUICtrlSetBkColor of the ListviewItem control.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

give me an example....

Share this post


Link to post
Share on other sites

give me an example....

I think you missed an operative word there ;) ... My kids would run for cover if they ever said "give me".

Why don't you provide a ListView to work with, and I'm sure someone can show you how to use it. (Or did you want them to "give" you that too?)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

give me an example....

The word you are looking for is 'please' :)

an example

#include <GUIConstants.au3>
#include <GuiListView.au3>

;create form
;whlt
$Form1 = GUICreate("AForm1", 370, 270, 193, 115)
;create listview
;ltwh
$ListView1 = GUICtrlCreateListView("000000|111111|222222222222222", 10, 10, 350, 250)
;set to alternate the colors
GUICtrlSetBkColor($ListView1, $GUI_BKCOLOR_LV_ALTERNATE)
;insert item
$ListView1_0 = GUICtrlCreateListViewItem("aaa|111|nononono", $ListView1)
;set alternate color
GUICtrlSetBkColor(-1, 0xffff00)
$ListView1_1 = GUICtrlCreateListViewItem("bbb|222|yes", $ListView1)
;set alternate color
GUICtrlSetBkColor(-1, 0xffff00)
$ListView1_2 = GUICtrlCreateListViewItem("ccc|333|nononono", $ListView1)
;set alternate color
GUICtrlSetBkColor(-1, 0xffff00)
;resize the columns to header
_GUICtrlListViewSetColumnWidth ($listview1, 0, $LVSCW_AUTOSIZE_USEHEADER)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

It took me a while to figure it out too.

Share this post


Link to post
Share on other sites

Hi,

and which way do you set the selected line? Lets say, I will read the input with GuiCtrlread ... and will select the line entered.

How will I do that? :">

#include <GUIConstants.au3>
#include <GuiListView.au3>

GUICreate("listview items", 220, 250, 100, 200, -1)
GUISetBkColor(0x00E0FFFF)  ; will change background color

$listview = GUICtrlCreateListView("Name  |Vorname |Alter  ", 10, 10, 200, 150, Default,$LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT);,$LVS_SORTDESCENDING)
_GUICtrlListViewSetColumnWidth($listview, 2, $LVSCW_AUTOSIZE_USEHEADER)
$button = GUICtrlCreateButton("OK", 75, 170, 70, 20)
$item1 = GUICtrlCreateListViewItem("Mega|Thorsten|27", $listview)
$item2 = GUICtrlCreateListViewItem("Blome|Dennis|26", $listview)
$item3 = GUICtrlCreateListViewItem("Schaefer|Rene|26", $listview)
$input1 = GUICtrlCreateInput("", 20, 200, 150)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUi_Event_Close
            Exit (0)
        Case $button
            ;GUICtrlSetState($item2, $GUI_Focus) 
            ;_GUICtrlListViewSetItemSelState ($listview, 1,1,1)
        Case $listview
            MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2)
    EndSwitch
WEnd

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

In its simplest form, it might look like:

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

GUICreate("AForm1", 370, 270, 193, 115)
$ListView1 = GUICtrlCreateListView("Name|Age|Sex", 10, 10, 350, 250)
GUICtrlSetBkColor($ListView1, $GUI_BKCOLOR_LV_ALTERNATE)
GUICtrlCreateListViewItem("Joe|26|Male", $ListView1)
GUICtrlCreateListViewItem("Mary|48|Female", $ListView1)
GUICtrlSetBkColor(-1, 0xf3f389)
GUICtrlCreateListViewItem("Jack|6|Male", $ListView1)
GUICtrlCreateListViewItem("Kittie|99|Female", $ListView1)
GUICtrlSetBkColor(-1, 0xf3f389)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

A GUICtrlSetBkColor call seems to be required for every row to be colored differently from white.


...chris

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