Jump to content

question about _GUICtrlListView_GetItemParam


lucio69f
 Share

Recommended Posts

Hi , i try to understund this function _GUICtrlListView_GetItemParam  i modify the example scritp   , but  i dont  understund  a mecanism about it 

 

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

Example()

Func Example()
    GUICreate("ListView Get/Set Item Param (v" & @AutoItVersion & ")", 400, 300)
    Local $idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListView, "Item 0")
    _GUICtrlListView_AddItem($idListView, "Item 1")
    _GUICtrlListView_AddItem($idListView, "Item 2")

    ; Set item 1 parameter
    ;_GUICtrlListView_SetItemParam($idListView, 1, 1234)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 Parameter: " & _GUICtrlListView_GetItemParam($idListView, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

i suppose  i must return if  set 1 in  _GUICtrlListView_GetItemParam(........., 1)  in message box must  appear  Item 1   , but  return 0  , why ???  thanks at all

Link to comment
Share on other sites

Because you never set the item param, at least not directly. Fourth parameter of _GUICtrlListView_AddItem() is exactly this param and by default is set to 0 so this is the value that you get when you use _GUICtrlListView_GetItemParam() unless you set another value for this parameter or if you set the param later.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

..that "parameter" is an integer used like a note. You can read the note/param and do stuff based on that parameter. Change font/colors/etc. . So you'd assign a parameter for your use. Is upto you ( your code ) to do something with it or not. That's why by default is just zero.

That should make sense as a non-programmer. :) 

NOTE: do read the remarks https://www.autoitscript.com/autoit3/docs/libfunctions/_GUICtrlListView_SetItemParam.htm

Look at https://www.autoitscript.com/forum/topic/89654-listview-for-every-subitem-set-color-backcol-and-font/ to see how it's used there.

 

Edited by argumentum
clarify

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

11 hours ago, argumentum said:

..that "parameter" is an integer used like a note. You can read the note/param and do stuff based on that parameter. Change font/colors/etc. . So you'd assign a parameter for your use. Is upto you ( your code ) to do something with it or not. That's why by default is just zero.

That should make sense as a non-programmer. :)

trhanks  now i understund  çD is  only  anote mmmm  

Link to comment
Share on other sites

but  why not  colored? 

 

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

Example()

Func Example()
    GUICreate("ListView Get/Set Item Param (v" & @AutoItVersion & ")", 400, 300)
    Local $idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListView, "Item 0",-1,3)
    _GUICtrlListView_AddItem($idListView, "Item 1")
    _GUICtrlListView_AddItem($idListView, "Item 2")

    ; Set item 1 parameter
    ;_GUICtrlListView_SetItemParam($idListView, 1, 1234)
        Local $ctrlID = _GUICtrlListView_GetItemParam($idListView, 3)
    GUICtrlSetBkColor($ctrlID, 0xCC7722)
    MsgBox($MB_SYSTEMMODAL, "Information", "Item 1 Parameter: " & _GUICtrlListView_GetItemParam($idListView, 0))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

47 minutes ago, lucio69f said:

trhanks  now i understund  çD is  only  anote mmmm  

No, you don't. First of all you assigned the value 3 as param for the first item (0 based index) of the list view but you read the param value of the 4th item (0 based index) which is still zero because it doesn't even exists. And even if you would get the param value for the first item, the value 3 used with GUICtrlSetBkolor() doesn't make any sense because what you read it's not a control ID, maybe just by chance.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

54 minutes ago, lucio69f said:

but  why not  colored? 

Because with your way, you can only color the whole listview, not individual cells. 

I already showed you how simple it is to do it in a previous post, remember ?

Edited by Nine
Link to comment
Share on other sites

10 hours ago, Andreik said:

No, you don't. First of all you assigned the value 3 as param for the first item (0 based index) of the list view but you read the param value of the 4th item (0 based index) which is still zero because it doesn't even exists. And even if you would get the param value for the first item, the value 3 used with GUICtrlSetBkolor() doesn't make any sense because what you read it's not a control ID, maybe just by chance.

but you  tell me the number 3 is only anote and i must use this not for call a line , why tell now  is 0 ???

Link to comment
Share on other sites

continue to not understund  sorry  why this  code  work

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

GUICreate("listview items", 220, 250, 100, 200)

Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 230)
For $i = 1 to 10
  GUICtrlCreateListViewItem("item" & $i & "|col" & $i & "2|col" & $i & "3", $idListview)
Next

LVBK ($idListview, 2, 0x00ff00)
LVBK ($idListview, 5, 0x00ff00)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func LVBK ($ListView, $row, $color)
  GUICtrlSetBkColor (_GUICtrlListView_GetItemParam($ListView, $row),$color)
EndFunc

and this code not work ?

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

Example()

Func Example()
    GUICreate("ListView Get/Set Item Param (v" & @AutoItVersion & ")", 400, 300)
    Local $idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListView, "Item 0")
    _GUICtrlListView_AddItem($idListView, "Item 1")
    _GUICtrlListView_AddItem($idListView, "Item 2")

    ; Set item 1 parameter

LVBK ($idListView, 0, 0x00ff00)
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func LVBK ($ListView, $row, $color)
  GUICtrlSetBkColor (_GUICtrlListView_GetItemParam($ListView, $row),$color)
EndFunc

 

Link to comment
Share on other sites

1 hour ago, lucio69f said:

continue to not understund  sorry  why this  code  work

On 11/17/2023 at 8:22 PM, argumentum said:

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

i notice if i use   GUICtrlCreateListViewItem("item" & $i & "|col" & $i & "2|col" & $i & "3", $idListview)   is  work but if  i use 

_GUICtrlListView_AddColumn($idListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListView, "Item 0",-1,3)
    _GUICtrlListView_AddItem($idListView, "Item 1")
    _GUICtrlListView_AddItem($idListView, "Item 2")

not  work , now  the  question is :  is not possible to use  because _GUICtrlListView_AddItem use  another principle or  is  possible to use also with _GUICtrlListView_AddItem  but  i am ignore  the the mode  to use t ?

Link to comment
Share on other sites

9 hours ago, argumentum said:

is  very complicated  like example  with dllsctrucutere  and  much more , i am not professionist programmer sorry

Link to comment
Share on other sites

10 hours ago, lucio69f said:

continue to not understund  sorry  why this  code  work

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

GUICreate("listview items", 220, 250, 100, 200)

Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 230)
For $i = 1 to 10
  GUICtrlCreateListViewItem("item" & $i & "|col" & $i & "2|col" & $i & "3", $idListview)
Next

LVBK ($idListview, 2, 0x00ff00)
LVBK ($idListview, 5, 0x00ff00)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func LVBK ($ListView, $row, $color)
  GUICtrlSetBkColor (_GUICtrlListView_GetItemParam($ListView, $row),$color)
EndFunc

and this code not work ?

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

Example()

Func Example()
    GUICreate("ListView Get/Set Item Param (v" & @AutoItVersion & ")", 400, 300)
    Local $idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListView, "Item 0")
    _GUICtrlListView_AddItem($idListView, "Item 1")
    _GUICtrlListView_AddItem($idListView, "Item 2")

    ; Set item 1 parameter

LVBK ($idListView, 0, 0x00ff00)
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Func LVBK ($ListView, $row, $color)
  GUICtrlSetBkColor (_GUICtrlListView_GetItemParam($ListView, $row),$color)
EndFunc

 

Because you fail to understand basic programming and you reject what other people already told you. In the second example _GUICtrlListView_GetItemParam() will return 0 no matter what index you will use because you never set param. Since this function will always return 0 and this value it's passed to GUICtrlSetBkColor() as control ID it's clear that won't work. Even if you would have set the param it would still not work because _GUICtrlListView_AddItem() does not return a control ID and GUICtrlSetBkColor() works just for controls returned by GUICtrlCreateListViewItem() and @Nine already told you that if you want to color items using GuiListView UDF you have to redraw the control by yourself.

When the words fail... music speaks.

Link to comment
Share on other sites

Look at the posted code, you didn't. But even if it's set it won't work because the value 3 doesn't mean anything. Maybe by chance it's the control ID of some control. This was already told you few times but you don't listen.

When the words fail... music speaks.

Link to comment
Share on other sites

On 11/18/2023 at 3:07 PM, Nine said:

Because with your way, you can only color the whole listview, not individual cells. 

I already showed you how simple it is to do it in a previous post, remember ?

i saw  but is  possible do it wihtout  WM_NOTIFY ???  is  very complicate  the paradigm  WM_NOTIFY

Link to comment
Share on other sites

Just now, Andreik said:

Look at the posted code, you didn't. But even if it's set it won't work because the value 3 doesn't mean anything. Maybe by chance it's the control ID of some control. This was already told you few times but you don't listen.

but  how  can set it ??   i saw  manual and  tell insert  number

Link to comment
Share on other sites

Set what? What are you trying to do?

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

Example()

Func Example()
    GUICreate("ListView Get/Set Item Param (v" & @AutoItVersion & ")", 400, 300)
    Local $idListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Add columns
    _GUICtrlListView_AddColumn($idListView, "Items", 100)

    ; Add items
    _GUICtrlListView_AddItem($idListView, "Item 0", -1, 3)
    _GUICtrlListView_AddItem($idListView, "Item 1")
    _GUICtrlListView_AddItem($idListView, "Item 2")

    For $Index = 0 To _GUICtrlListView_GetItemCount($idListView) - 1
        ConsoleWrite('Param value of item ' & $Index & ' is: ' & _GUICtrlListView_GetItemParam($idListView, $Index) & @CRLF)
    Next

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

Your problem is not to set/get param but what it means what you set as param. The value 3 set as param for first item of list view doesn't mean anything, it's just a value, it's not a control ID so you cannot use it with GUICtrlSetBkColor(). Is that simple.

Edited by Andreik

When the words fail... music speaks.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...