58fly 发表于 2014-3-6 21:11:04

关于listview设置交叉背景色的问题~

#cs ____________________________________

AutoIt 版本: 3.2.11.0(第一版)
脚本作者:
        Email:
        QQ/TM:
脚本版本:
脚本功能:

#ce _______________脚本开始_________________

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

Opt("GUIOnEventMode", 1)

Global $Title="my title"
Global $ListView1,$wl

$h_GUI = GUICreate($Title,410,230)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

;问题是添加控件项目后,在刷新时ListView控件就会闪烁,而且慢了很多
$tab = GUICtrlCreateTab(5,5,400,200); 1.不用Tab就正常
GUISetFont (9, 400)

;第1分页
$tab0 = GUICtrlCreateTabItem("tab0") ; 2.不添加控件项目也会正常

$Ok=GUICtrlCreateButton("刷新",350,50)
GUICtrlSetOnEvent($Ok,"OK")

$ListView1 = GUICtrlCreateListView("简称|全称|编号", 40, 40, 300,140)

GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES));, $LVS_EX_TRACKSELECT))
_GUICtrlListView_SetColumnWidth($ListView1, 0, 40)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 150)
_GUICtrlListView_SetColumnWidth($ListView1, 2, 40)

$wl = IniReadSection("file.ini", "myfile")
        If @error Then
                MsgBox(0, "", "错误,无法打开配置文件!")
        EndIf

;GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
        Sleep(100)
WEnd

Func Close()
        Exit
EndFunc

;~ Func OK()
;~ _GUICtrlListView_DeleteAllItems($ListView1)
;~ ;MsgBox(0,"","个数"&$wl)
;~         For $i = 1 To $wl
;~                 GUICtrlCreateListViewItem($wl[$i]&"|"&$wl[$i],$ListView1)
;~         Next
;~ MsgBox(0,"","结束")
;~ EndFunc

Func OK()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
Global $n=0
For $i = 1 To $wl
$var=StringSplit($wl[$i],"|")
;MsgBox(64,"",$var)
;GUICtrlCreateListViewItem($wl[$i]&"|"&$wl[$i],$ListView1)
_GUICtrlListView_AddItem($ListView1, $var)
_GUICtrlListView_AddSubItem($ListView1, $n,$var,1)
_GUICtrlListView_AddSubItem($ListView1, $n,$wl[$i],2)
_GuiListView_SetItemColor($ListView1, 0xEEEEEE,$n)
;~         $iID = _GUICtrlListView_MapIndexToID($ListView1, $n)
;~         GUICtrlSetBkColor(GUICtrlRead($iID) ,0xEEEEEE)
$n+=1
Next
MsgBox(0,"","结束")
EndFunc

Func _GuiListView_SetItemColor($hWnd, $Color,$index)
        ;MsgBox(64,"",_GUICtrlListView_GetSelectionMark($hWnd))
      $iItem = _GUICtrlListView_GetItemParam($hWnd,$index)
      Return GUICtrlSetbkColor($iItem, $Color)
EndFunc


以上代码设置交叉背景色无效,请教~

netegg 发表于 2014-3-7 23:42:57

http://www.autoitx.com/thread-15521-1-1.html
页: [1]
查看完整版本: 关于listview设置交叉背景色的问题~