Sign in to follow this  
Followers 0
sady

Need help!

7 posts in this topic

Hello.

Im from Russia so please excuse me for my bad english. :">

I have an issue with changing of colors for the item created by _GUICtrlListViewInsertItem.

I prefer to use _GUICtrlListViewInsertItem because of the limitation in amount of items created by GUICtrlCreateListViewItem (my application displaying the huge log files (200 000 lines) in the ListView.)

Instead of problem with colors everything works fine.

Please, let me know if anyone knows workaround of this issue:

Works:

1. $item = GUICtrlCreateListViewItem($message, $field)

2. GUICtrlSetColor($item,0xFF0000)

Need help:

1. $item = _GUICtrlListViewInsertItem($field, -1, $message)

2. ????????????

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello.

Im from Russia so please excuse me for my bad english. :">

I have an issue with changing of colors for the item created by _GUICtrlListViewInsertItem.

I prefer to use _GUICtrlListViewInsertItem because of the limitation in amount of items created by GUICtrlCreateListViewItem (my application displaying the huge log files (200 000 lines) in the ListView.)

Instead of problem with colors everything works fine.

Please, let me know if anyone knows workaround of this issue:

Works:

1. $item = GUICtrlCreateListViewItem($message, $field)

2. GUICtrlSetColor($item,0xFF0000)

Need help:

1. $item = _GUICtrlListViewInsertItem($field, -1, $message)

2. ????????????

The below doesn't work?

$item = _GUICtrlListViewInsertItem($field, -1, $message)
GUICtrlSetColor($field, 0xFF0000)

Edit:

Nope, it looks like it doesn't return a Control ID it returns the number it was placed in at in the List View.

Edited by SmOke_N

[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

#include <GuiConstants.au3>
#include <GuiListView.au3>

;~ Const $LVS_SORTDESCENDING = 0x0020
opt('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index
GUICreate("ListView Insert Item", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)
GUICtrlCreateLabel("Enter Item # to Insert To:", 90, 190, 130, 20)
$Input_Index = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
$Btn_Insert = GUICtrlCreateButton("Insert Item", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
         ExitLoop
      Case $msg = $Btn_Insert
         If (StringLen(GUICtrlRead($Input_Index)) > 0) Then
            $ret = _GUICtrlListViewInsertItem ($listview, Int(GUICtrlRead($Input_Index)), "test|1|2")
            If ($ret <> $LV_ERR) Then
               GUICtrlSetData($Status, 'Inserted Item at: ' & $ret)
                    $ret = _MapToID($listview, $ret)
                    If Not @error Then GUICtrlSetBkColor($ret, 0x6459ed)
            Else
               GUICtrlSetData($Status, 'Failed to Insert Item')
            EndIf
         Else
            GUICtrlSetData($Status, 'Must enter a Item Index to insert')
         EndIf
   EndSelect
WEnd
Exit

Func _MapToID(ByRef $listview, $i_index)
    Local $v_ret
    Local Const $LVM_FIRST = 0x1000
    Local Const $LVM_MAPINDEXTOID = $LVM_FIRST + 180
    If Not IsHWnd($listview) Then
        Return GUICtrlSendMsg($listview, $LVM_MAPINDEXTOID, $i_index, 0)
    Else
        Local $v_ret = DllCall("user32.dll","int","SendMessage", "hwnd", $listview, "int", $LVM_MAPINDEXTOID, "int", $i_index, "int", 0)
        If Not @error Then Return $v_ret[0]
        Return SetError(-1,-1,"")
    EndIf
EndFunc


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you, your function is really working and changing the color of gui controls but not fully correct (others GUI controls were colored instead of ListView items, after few attempts of applying of this function)

I replaced my code:

1. $item = GUICtrlCreateListViewItem($message, $field)
2. GUICtrlSetColor($item,0xFF0000)

To the one bellow:

1. $item_index =  _GUICtrlListViewInsertItem($field, -1, $message)
2. $item_id = _MapToID($field, $item_index)
3. GUICtrlSetColor($item_id,0xFF0000)

Maybe I did something wrong? :)

The one thing I need changing of color of last ListView item right after I create it

Maybe it will make a task easy?

Edited by sady

Share this post


Link to post
Share on other sites

Thank you, your function is really working and changing the color of gui controls but not fully correct (others GUI controls were colored instead of ListView items, after few attempts of applying of this function)

I replaced my code:

1. $item = GUICtrlCreateListViewItem($message, $field)
2. GUICtrlSetColor($item,0xFF0000)

To the one bellow:

1. $item_index =  _GUICtrlListViewInsertItem($field, -1, $message)
2. $item_id = _MapToID($field, $item_index)
3. GUICtrlSetColor($item_id,0xFF0000)

Maybe I did something wrong? :)

The one thing I need changing of color of last ListView item right after I create it

Maybe it will make a task easy?

Looks like a problem for Holger, the problem is with using the Insert the AutoIt control Id is not generated.

The MapToId may be a unique Listview item id but it not may not be unique to the gui.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Looks like a problem for Holger, the problem is with using the Insert the AutoIt control Id is not generated.

The MapToId may be a unique Listview item id but it not may not be unique to the gui.

Any ideas instead of using Excel UDFs?

Share this post


Link to post
Share on other sites

Did not find a workaround yet.... Need help.. Please...

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