Jump to content
Sign in to follow this  
Kyme

ListView question

Recommended Posts

Kyme

hi all

i try to make some tool to storage some data and i have a problem...for example in my below script when i press the head of column nothing happen...i mean it's didn't autoarange by number or by letters

can someone help me to make some function or some like that...when i press head of nr column to autoarange like 1,2,4,8,11,12,53 and the corestopndent on the secound column for 1 to be 1 on same line

if it's some posibility to make autoarange by letters will be awesome like a,b,c,d,e,f,g....

tnx all

Regards, Kyme

#include <GUIConstants.au3>
$menu = GUICreate("test", 225, 300, 202, 127)
$listphone = GUICtrlCreateListView("Nr|Data", 0, 0, 225, 300)

GUICtrlCreateListViewItem("1|1",$listphone)
GUICtrlCreateListViewItem("4|4",$listphone)
GUICtrlCreateListViewItem("12|12",$listphone)
GUICtrlCreateListViewItem("2|2",$listphone)
GUICtrlCreateListViewItem("53|53",$listphone)
GUICtrlCreateListViewItem("8|8",$listphone)
GUICtrlCreateListViewItem("11|11",$listphone)

GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    $tray=TrayGetMsg()
    Select 
        Case $Msg= $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Share this post


Link to post
Share on other sites
BrettF
Kyme

ZOMG. Its in the helpfile!

_GUICtrlListView_*

hi Brettf

look on my script...i have look in help and honest i don't get how to add this one to my script:|

#include <GUIConstants.au3>
Opt("TrayMenuMode",1)
$x=0
$Form1 = GUICreate("Nr Storage", 225, 300, 202, 127)
$listphone = GUICtrlCreateListView("Nr|Name|Phone", 0, 0, 225, 300)
$readnr=TrayCreateItem("Read")
GUISetState(@SW_SHOW)
allread()

While 1
    $Msg = GUIGetMsg()
    $tray=TrayGetMsg()
    Select 
        Case $Msg= $GUI_EVENT_CLOSE
            Exit
        case $tray= $readnr
            allread()
    EndSelect
WEnd

Func allread()
$readsection = IniReadSectionNames("data.txt")
If @error Then
    MsgBox(4096, "", "No file To Read")
Else
    For $i = 1 To $readsection[0]
        $name=IniRead("data.txt",$readsection[$i],"name","")
        $nr=IniRead("data.txt",$readsection[$i],"nr","")
        $ListView1_0 = GUICtrlCreateListViewItem($readsection[$i]&"|"&$name&"|"&$nr, $listphone)
    Next
EndIf
EndFunc

data.txt

[102]
name=xxxxx
nr=xxxx
[2]
name=xxxxx
nr=xxxxx
[55]
name=xxxxx
nr=xxxxx
[4]
name=xxxxx
nr=xxxxx
[5]
name=xxxxx
nr=xxxx
[6]
name=xxxxx
nr=xxxxx
[7]
name=xxxxx
nr=xxxxx
[8]
name=xxxxx
nr=xxxxx
[9]
name=xxxxx
nr=xxxx
[10]
name=xxxxx
nr=xxxxx
[11]
name=xxxxx
nr=xxxxx
[12]
name=xxxxx
nr=xxxxx
[13]
name=xxxxx
nr=xxxxx
[104]
name=xxxxx
nr=xxxxx
[105]
name=xxx
nr=xxxxx
[16]
name=xxx
nr=xxxxx
[17]
name=xxxxx
nr=xxxxx
[18]
name=xxxxx
nr=xxxxx
[20]
name=xxxxx
nr=xxxx
[201]
name=xxxxx
nr=xxxxx
[207]
name=xxxxx
nr=xxxxx
[47]
name=xxxxx
nr=xxxxx

can you help me please to add this?

Share this post


Link to post
Share on other sites
BrettF

Share this post


Link to post
Share on other sites
Kyme

Not sure where you've even tried. Take a look at _GUICtrlListView_SimpleSort.

Have a go, then if u still have trouble, post back here.

Cheers,

Brett

i've been tried other one first time...now i figurate how this think work and i made it...lol:))) 1hour past lol

tnx dude for help,you rock

Regards,Kyme

Share this post


Link to post
Share on other sites
BrettF
Kyme

And thats what happens when you try, fail and try again. :)

yep...never give up...

now i have other minor thing...

i save in item number phones and they start with 0 for ex 0744xxxxxx

and when i press the head column the autoarange it's ok but the 0 it's not there anymore...can be this fixed? i use WM_NOTIFY function as i saw in simple

here it's the func

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $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_COLUMNCLICK; A column was clicked
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    _DebugPrint("$LVN_COLUMNCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    _GUICtrlListView_SimpleSort ($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
                   ; No return value
                Case $LVN_KEYDOWN; A key has been pressed
                    Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
                    _DebugPrint("$LVN_KEYDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @LF & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                   ; No return value
                Case $NM_CLICK; Sent by a list-view control when the user clicks an item with the left mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                   ; No return value
                Case $NM_DBLCLK; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                   ; No return value
                Case $NM_KILLFOCUS; The control has lost the input focus
                    _DebugPrint("$NM_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                   ; No return value
                Case $NM_RCLICK; Sent by a list-view control when the user clicks an item with the right mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                   ;Return 1; not to allow the default processing
                    Return 0; allow the default processing
                Case $NM_RDBLCLK; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode & @LF & _
                            "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
                            "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
                            "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
                            "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
                            "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
                            "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
                            "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
                            "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
                            "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                   ; No return value
                Case $NM_RETURN; The control has the input focus and that the user has pressed the ENTER key
                    _DebugPrint("$NM_RETURN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                   ; No return value
                Case $NM_SETFOCUS; The control has received the input focus
                    _DebugPrint("$NM_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                   ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

thank you all

Share this post


Link to post
Share on other sites
BrettF
ds34

Looking at this topic, I would like to improve my _arraydisplay_ex to be able to edit single cells and change the saved value in the the displayed array.

So in the notifier lines:

CODE
Case $NM_DBLCLK; Sent by a list-view control when the user double-clicks an item with the left mouse button

Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)

Local $items[2]

$items[0]=DllStructGetData($tInfo, "Index");

$items[1]=DllStructGetData($tInfo, "SubItem")-1

Return $items;

I can determine the clicked cell for my 2D array.

How do I pass back the the $items into the _arraydisplay?

The notifier is registered via GUIRegisterMsg so I can't just use a normal function call.

In order to modify the my originally displayed array upon double click on a cell I would need either to pass back the cell coordinates to the _arraydisplayex or to pass the displayed array towards the notifier.

Any clever suggestions?

Share this post


Link to post
Share on other sites
ds34

CODE
Case $NM_DBLCLK; Sent by a list-view control when the user double-clicks an item with the left mouse button

Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)

Local $items[2]

$items[0]=DllStructGetData($tInfo, "Index");

$items[1]=DllStructGetData($tInfo, "SubItem")-1

Meanwhile I've found a way (maybe not clever but working, and just just post it here for sake of completness):

In the calling routine (in may example the _arraydisplayex) I create a dummycontrol (global scope var)

The code above is needed to e changed that $items has global scope too. In stead of Return I send a GUICtrlSendToDummy( $DummyControl)

Now I can handle the Dummycontrol event in the arraydisplayex GUI and open input box and overwrite the cell value based on the lobal position read from $items...

Edited by ds34

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  

×