找回密码
 加入
搜索
查看: 1372|回复: 4

请教关于GUICtrlCreateListView文件本行颜色问题。

[复制链接]
发表于 2009-5-25 19:01:53 | 显示全部楼层 |阅读模式
本帖最后由 ddx13 于 2009-5-25 20:42 编辑

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 448, 456, 192, 114)
$ListView = GUICtrlCreateListView("item2|col22|col23", 0, 0, 446, 454)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlCreateListViewItem("item2|col22|col23", $listview)
GUICtrlCreateListViewItem("item1|col12|col13", $listview)
GUICtrlCreateListViewItem("item3|col32|col33", $listview)
GUICtrlCreateListViewItem("item4|col42|col43", $listview)
GUICtrlCreateListViewItem("item5|col52|col53", $listview)
GUICtrlCreateListViewItem("item6|col62|col63", $listview)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd


代码中GUICtrlCreateListView为黑色,但是因为有些要特别突现出来。
我的意思,比如一行文件色是黑色,第二行文件色是黑色,但是到第三行的时候文件色要红色。而后面的又变成了文件是黑色。找了半天也没有找到相关的例子,会的告诉请指教一下。谢谢。
 楼主| 发表于 2009-5-25 20:43:21 | 显示全部楼层
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$ListView1 = GUICtrlCreateListView("1", 136, 72, 250, 150)
                        GUICtrlCreateListViewItem("1", $ListView1)
                        GUICtrlSetBkColor(-1, 0xff0000)
                                                GUICtrlCreateListViewItem("2", $ListView1)
                        GUICtrlSetBkColor(-1, 0x00ff00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

        EndSwitch
WEnd
发表于 2009-5-25 21:14:23 | 显示全部楼层
楼主你骗人 明明你说的是color不是bkcolor....
因为udf里settextcolor只能设置整个listview的颜色所以我就没回帖
 楼主| 发表于 2009-5-26 08:50:38 | 显示全部楼层
先说声谢谢了,可能是我表达的不清楚,不过你说的那种,我在官网论坛里搜索到了。N麻烦。不过我还是留下来了,以防以后用到。
 楼主| 发表于 2009-5-26 08:52:03 | 显示全部楼层
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $hListItem[2]
Global $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $aHit
Global $iColor, $iColorBk, $fChildGui = False

$Main_GUI = GuiCreate("test", 924, 604, 60, 20)
$hListView = GuiCtrlCreateListView("", 10, 44, 904, 535, -1, BitOR($LVS_ICON, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_TWOCLICKACTIVATE))
$hListView = GUICtrlGetHandle($hListView) ; necessary for _SubItemHitTest
_GUICtrlListView_AddColumn($hListView, " ", 20)
_GUICtrlListView_AddColumn($hListView, "TIME", 40, 1)
_GUICtrlListView_AddColumn($hListView, "PROVIDER ", 70)
_GUICtrlListView_AddColumn($hListView, "CHART # ", 70)
_GUICtrlListView_AddColumn($hListView, "PATIENT NAME ", 155)
_GUICtrlListView_AddColumn($hListView, "NOTE ", 158)
_GUICtrlListView_AddColumn($hListView, "RESOURCE", 72)
_GUICtrlListView_AddColumn($hListView, "STATUS ", 74)
_GUICtrlListView_AddColumn($hListView, "CLAIM(S) ", 80)
_GUICtrlListView_AddColumn($hListView, "LEDGER", 72)
_GUICtrlListView_AddColumn($hListView, "DICTATION", 72)

$Status_Message = GUICtrlCreateLabel("", 20, 582, 180, 20)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

;_GUICtrlListView_BeginUpdate($hListView)
$hListItem[1] = _GUICtrlListView_AddItem($hListView, " ")
_GUICtrlListView_AddSubItem($hListView, 0, "11:30", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "XYZZY", 2)
_GUICtrlListView_AddSubItem($hListView, 0, "PLUGH", 3)
_GUICtrlListView_AddSubItem($hListView, 0, "DOE, JOHN", 4)
_GUICtrlListView_AddSubItem($hListView, 0, "PLOVER", 5)
_GUICtrlListView_AddSubItem($hListView, 0, "FOOBAR", 6)
_GUICtrlListView_AddSubItem($hListView, 0, "CLICK ME", 7)
_GUICtrlListView_AddSubItem($hListView, 0, "12345", 8)
_GUICtrlListView_AddSubItem($hListView, 0, "01-01-2009", 9)
_GUICtrlListView_AddSubItem($hListView, 0, "01-31-2009", 10)   
;_GUICtrlListView_EndUpdate($hListView)

;-----------------------------------------------------------------------------------------------------------
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3 ; $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    If $fChildGui Then
        Child_GUI($aHit[0])
        $fChildGui = False
    EndIf
Wend
Exit

;-----------------------------------------------------------------------------------------------------------
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_ENDSCROLL
                    $tNMHDR = DllStructCreate("hwnd hWnd;uint cID;int code", $ilParam)
                    $hLV = HWnd(DllStructGetData($tNMHDR, "hWnd"))
                    _WinAPI_InvalidateRect($hLV)
                Case $NM_DBLCLK
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $aHit = _GUICtrlListView_SubItemHitTest($hListView)
                    If $aHit[0] < 0 Then Return $GUI_RUNDEFMSG
                    Switch $aHit[1]
                        Case 7
                            $fChildGui = True
                            ;Child_GUI($aHit[0])
                    EndSwitch
                Case $NM_CUSTOMDRAW
                    Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam)
                    Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")
                    If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW
                    If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW
                    Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
                    Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")
                  
                    If $iSubItem Then
                        $iColor = 0x000000
                        $iColorBk = 0xFFFFFF
                        Switch $iSubItem
                            Case 4
                                $iColor = 0xFFFFFF
                                $iColorBk = 8421376
                            Case 6
                                $iColor = 0x0080FF
                            Case 7
                                $iColor = 0x888888
                            Case 8
                                $iColor = 0x228B22
                            Case 9
                                $iColor = 0xFF0000
                            Case 10
                                $iColor = 0x0000FF
                        EndSwitch
                        DllStructSetData($tCustDraw, "clrTextBk", $iColorBk)
                        DllStructSetData($tCustDraw, "clrText", $iColor)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

;-----------------------------------------------------------------------------------------------------------
Func Child_GUI($y)
;   GUISetState(@SW_LOCK, $Main_GUI) ; uncommented changes behaviour
    $APPTSTAT_GUI = GUICreate("", 230, 180, 560, 140)
    GUISetState(@SW_SHOW, $APPTSTAT_GUI)
    While 1
        $msg2 = GUIGetMsg()
        Switch $msg2
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
        Sleep(50) ; why is this necessary? otherwise crashes
    Wend
    GUIDelete($APPTSTAT_GUI)
    GUISetState(@SW_RESTORE, $Main_GUI)
;   GUISetState(@SW_UNLOCK, $Main_GUI); uncommented changes behaviour
EndFunc

评分

参与人数 1金钱 +5 收起 理由
lynfr8 + 5 原创内容,感谢你对论坛的支持;希望继续发 ...

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-5 18:56 , Processed in 0.076581 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表