Sign in to follow this  
Followers 0
Gillboss

Set Icon On Specific Line In List View

14 posts in this topic

#1 ·  Posted (edited)

other quetion:

well thats hard.. i have other quetion..

there is the script:

$hImage = _GUIImageList_Create(16, 16, 5, 3)

_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 112)

_GUICtrlListView_SetImageList($hListView, $hImage, 1)

it set icon at all my list. can i make it for specific line?

thanks!

Edited by Gillboss

Share this post


Link to post
Share on other sites



Did you try GUICtrlSetBkColor?

Share this post


Link to post
Share on other sites

not work.. i tried:

_GUICtrlListView_SetTextColor($hListView[2], 0xff0000)

with hope it will set line 2 at color red but its error

Share this post


Link to post
Share on other sites

?

Share this post


Link to post
Share on other sites

some1 know?

Share this post


Link to post
Share on other sites

Take time to learn how to search, it will pay off many times over.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Coloring only some lines is not easy. Some time ago, I tried to make it. It works, but the code looks not vwery well muttley http://www.autoit.de/index.php?page=Thread...35376#post35376


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Take time to learn how to search, it will pay off many times over.

funny..

i search: "set text list color" and didnt see nothing!!!!

http://www.autoitscript.com/forum/index.ph...id=545604&#

Coloring only some lines is not easy. Some time ago, I tried to make it. It works, but the code looks not vwery well muttley http://www.autoit.de/index.php?page=Thread...35376#post35376

whats code? i am not understand German..

Edited by Gillboss

Share this post


Link to post
Share on other sites

Search Examples forum for "customdraw"

Share this post


Link to post
Share on other sites

funny..

i search: "set text list color" and didnt see nothing!!!!

That's not funny, that just proves my point.

Anyway, since I want to be done with you ASAP and put you back on my ignore list where you rightfully belong, see this for example:

#470173


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

http://www.autoit.de/index.php?page=Thread...35376#post35376

whats code? i am not understand German..

The code is in the spiler. And it's commented a bit in English muttley

I made it from an example Script from here, but I don't know the Link anymore.

CODE
#AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7

Opt("MustDeclareVars", 1)

#include <GuiConstantsEx.au3>

#include <WindowsConstants.au3>

#include <GuiListView.au3>

#include <GuiImageList.au3>

#include <GuiStatusbar.au3>

#include <Constants.au3>

;---------------------------

; Saves the ListViewItem Background Colors

Global $_ListView_BKColors[1]

;Array for text color

Global $_ListView_ForeColors[1]

;---------------------------

;~ Global Const $tagNMLVCUSTOMDRAW = "hwnd hWndFrom;int IDFrom;int Code;dword dwDrawStage;hwnd hdc;int Left;int Top;int Right;int Bottom;" & _

;~ "dword dwItemSpec;uint uItemState;long lItemlParam;int clrText;int clrTextBk;int iSubItem;dword dwItemType;int clrFace;int iIconEffect;" & _

;~ "int iIconPhase;int iPartId;int iStateId;int TextLeft;int TextTop;int TextRight;int TextBottom;uint uAlign"

;~ Global Const $CDDS_PREPAINT = 0x00000001

;~ Global Const $CDDS_ITEMPREPAINT = 0x00010001

;~ Global Const $CDRF_NEWFONT = 0x00000002

;~ Global Const $CDRF_NOTIFYITEMDRAW = 0x00000020

#region Globals *************************************************************************

Global $hDragImageList, $h_ListView, $bDragging = False, $LV_Height, $StatusBar1

Global $a_index[2] ; from and to

Global Const $DebugIt = 1

#endregion End Global variables

Opt("WinTitleMatchMode", 2)

_TestDragItemWithImages()

Func _TestDragItemWithImages()

Local Const $image_width = 20

Local Const $image_height = 20

Local $h_images, $main_GUI, $iIndex

$main_GUI = GUICreate("GuiRegisterMsg Test", 225, 400)

$h_ListView = _GUICtrlListView_Create($main_GUI, "Entry Name|Category", 5, 75, 220, 280, -1, BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))

$LV_Height = 280 - 75

_GUICtrlListView_SetColumnWidth($h_ListView, 0, 100)

_GUICtrlListView_SetColumnWidth($h_ListView, 1, 100)

_GUICtrlListView_SetExtendedListViewStyle($h_ListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))

;-----------------------------------------------------

;Register WM_NOTIFY events

;Here the ListView-Background-Colors will be painted.

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

;------------------------------------------------------

Local $y = 1

For $x = 0 To 9

$iIndex = _GUICtrlListView_AddItem($h_ListView, "Name " & $x + 1, $y) ; handle, string, image index

_GUICtrlListView_AddSubItem($h_ListView, $iIndex, "Category " & $x + 1, 1, $y + 1) ; handle, index, string, subitem, image index

$y += 2

Next

_ListView_SetItemColor($h_ListView,0x0000FF,2)

_ListView_SetItemColor($h_ListView,0x00FF00,1) ; Sets the BG- Color

GUISetState()

While 1

Switch GUIGetMsg()

Case $GUI_EVENT_CLOSE

ExitLoop

EndSwitch

WEnd

EndFunc ;==>_TestDragItemWithImages

;

; WM_NOTIFY event handler

Func WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)

#forceref $hWndGUI, $MsgID, $wParam

Local $tNMHDR, $code, $x, $y, $tNMLISTVIEW, $hwndFrom, $tDraw, $dwDrawStage, $dwItemSpec, $test

$tNMHDR = DllStructCreate($tagNMHDR, $lParam) ;NMHDR (hwndFrom, idFrom, code)

If @error Then Return

$code = DllStructGetData($tNMHDR, "Code")

$hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")

Switch $hwndFrom

;---------------------------------------------------------

Case $h_ListView ;---------> Here goes the ListView Gui-Variable

;---------------------------------------------------------

Switch $code

Case $NM_CUSTOMDRAW

;~ If $DebugIt Then _DebugPrint("$NM_CUSTOMDRAW")

$tDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)

$dwDrawStage = DllStructGetData($tDraw, "dwDrawStage")

$dwItemSpec = DllStructGetData($tDraw, "dwItemSpec")

Switch $dwDrawStage

Case $CDDS_PREPAINT

Return $CDRF_NOTIFYITEMDRAW

Case $CDDS_ITEMPREPAINT

If $dwItemSpec < UBound($_ListView_BKColors) Then

If IsNumber($_ListView_BKColors[$dwItemSpec]) Then DllStructSetData($tDraw, "clrTextBk", $_ListView_BKColors[$dwItemSpec])

;MsgBox(0,"", $hWndGUI & @CRLF & $MsgID & @CRLF & $wParam & @CRLF & $lParam)

EndIf

If $dwItemSpec < UBound($_ListView_ForeColors) Then

If IsNumber($_ListView_ForeColors[$dwItemSpec]) Then DllStructSetData($tDraw, "clrText", $_ListView_ForeColors[$dwItemSpec])

;MsgBox(0,"", $hWndGUI & @CRLF & $MsgID & @CRLF & $wParam & @CRLF & $lParam)

EndIf

Return $CDRF_NEWFONT

EndSwitch

EndSwitch

EndSwitch

Return $GUI_RUNDEFMSG

EndFunc ;==>WM_NOTIFY

#endregion Event Function(s)

Func _ListView_SetItemColor($ListView, $Color, $Index, $redraw = 1)

ReDim $_ListView_BKColors[_GUICtrlListView_GetItemCount($ListView)+1]

If Not ($Index < UBound($_ListView_BKColors)) Then Return Seterror(1,0,0)

$_ListView_BKColors[$Index] = $Color

If $Color = Default Then $_ListView_BKColors[$Index]=""

If $redraw Then DLLCAll("user32.dll","int","RedrawWindow","hwnd", $ListView,"int",0,"int",0,"int",0x1)

EndFunc ; <--| _ListView_SetItemColor

Func _ListView_SetItemFontColor($ListView, $Color, $Index, $redraw = 1)

ReDim $_ListView_ForeColors[_GUICtrlListView_GetItemCount($ListView)+1]

If Not ($Index < UBound($_ListView_ForeColors)) Then Return Seterror(1,0,0)

$_ListView_ForeColors[$Index] = $Color

If $Color = Default Then $_ListView_ForeColors[$Index]=""

If $redraw Then DLLCAll("user32.dll","int","RedrawWindow","hwnd", $ListView,"int",0,"int",0,"int",0x1)

EndFunc ; <--| _ListView_SetItemColor


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

why, when i use this function:

_ListView_SetItemColor

i get error "Unknown Function"?

edit:

oh oops i didnt see its function name muttley

Edited by Gillboss

Share this post


Link to post
Share on other sites

why, when i use this function:

_ListView_SetItemColor

i get error "Unknown Function"?

That's very strange.

When I block comment out the last two functions in the script I copied across, I get:-

ERROR: _ListView_SetItemColor(): undefined function.

Share this post


Link to post
Share on other sites

well thats hard.. i have other quetion..

there is the script:

$hImage = _GUIImageList_Create(16, 16, 5, 3)

_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 112)

_GUICtrlListView_SetImageList($hListView, $hImage, 1)

it set icon at all my list. can i make it for specific line?

thanks!

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