Sign in to follow this  
Followers 0
Krikov

ListView Sort Probelm

3 posts in this topic

Hello,

i dont Know What is Wrong With My Sort Option Please Can Some One Help Me

#include <GUIConstants.au3>
#include <GuiListView.au3>

GUICreate("listview items", 978, 547, 17, 115,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF) 
Dim $listview
$listview = GUICtrlCreateListView ("DisplayName|ProcessId|StartMode|StartName|State|Status" ,8, 8, 961, 500,$LVS_SORTASCENDING)
GUISetState()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output=""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Service", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

If IsObj($colItems) then
   For $objItem In $colItems
      $Output = $Output&$objItem.DisplayName&"|"
      $Output = $Output&$objItem.ProcessId&"|"
      $Output = $Output&$objItem.StartMode&"|"
      $Output = $Output&$objItem.StartName&"|"
      $Output = $Output&$objItem.State&"|"
      $Output = $Output&$objItem.Status
      GUICtrlCreateListViewItem($Output,$listview)
      $Output=""
   Next
Else
   Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Service" )
Endif
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview)]
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $listview
        _GUICtrlListViewSort($listview,$B_DESCENDING,GUICtrlGetState($listview))    
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

Krikov


[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

don't set the sort flag when creating the listview

#include <GUIConstants.au3>
#include <GuiListView.au3>

GUICreate("listview items", 978, 547, 17, 115, -1, $WS_EX_ACCEPTFILES)
GUISetBkColor(0x00E0FFFF)
Dim $listview
$listview = GUICtrlCreateListView("DisplayName|ProcessId|StartMode|StartName|State|Status", 8, 8, 961, 500)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUISetState()
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output = ""
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Service", "WQL", _
        $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
GUISetState(@SW_LOCK)
If IsObj($colItems) Then
    For $objItem In $colItems
        $Output = $Output & $objItem.DisplayName & "|"
        $Output = $Output & $objItem.ProcessId & "|"
        $Output = $Output & $objItem.StartMode & "|"
        $Output = $Output & $objItem.StartName & "|"
        $Output = $Output & $objItem.State & "|"
        $Output = $Output & $objItem.Status
        GUICtrlCreateListViewItem($Output, $listview)
        $Output = ""
    Next
Else
    MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_Service")
EndIf
Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ]
_GUICtrlListViewSort ($listview, $B_DESCENDING, 0)
GUISetState(@SW_UNLOCK)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $listview
            GUISetState(@SW_LOCK)
            _GUICtrlListViewSort ($listview, $B_DESCENDING, GUICtrlGetState($listview))
            GUISetState(@SW_UNLOCK)
        Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit
Edited by gafrost

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

Thanks Man You Are The Best

Krikov


[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

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