Sign in to follow this  
Followers 0
JohnWang

_GUICtrlListViewSort

4 posts in this topic

Hi

I find out that _GUICtrlListViewSort doesnt work with my program... here is my code.

;Includes

#include <GUIConstants.au3>

#include <File.au3>

#Include <GuiListView.au3>

;Variables

dim $LibraryPath = @ScriptDir & "\Library\TweakUI.ini"

dim $mainGUI

dim $mainGUIWidth = (@DesktopWidth/7)*5

dim $mainGUIHeight = (@DesktopHeight/3)*2

dim $fileMenu

dim $fileMenuItems[3]dim $fileMenuItemsSub[5]

dim $modeMenu

dim $modeMenuItems[1]

dim $helpMenu

dim $helpMenuItems[3]

dim $Seperators[5]

dim $Banner

dim $ListGroup

dim $ListView

dim $ListViewItem[50]

dim $TweakDesc

dim $TweakType

dim $applyBtn

dim $LabelGroup

dim $DescLabel

dim $RegKey[50]

dim $RegSub[50]

dim $RegType[50]

dim $RegValue[50]

dim $RegInfo[50]

dim $RegDefaultValue[50]

dim $RegRecommanded[20]

dim $tempCheck

dim $Selected = 0

;Declarations

dim $NumberOfRegEntries = 0

;AutoIt Options

opt("MustDeclareVars", 1)

opt("TrayIconDebug", 1)

opt("GUIOnEventMode", 1)

;Main

onstart()

while 1

GUiSetOnEvent($GUI_EVENT_CLOSE,"onExit",$mainGUI)

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN,"InfoDisplay",$mainGUI)

HotKeySet("{F5}","onRefresh")

Sleep(50)

Wend

;Functions

Func onstart()

$NumberOfRegEntries = iniRead($LibraryPath,"Number Of Entries","Number",-1)

If $NumberOfRegEntries > 0 Then

MainGUI()

Else

$LibraryPath= FileOpenDialog("Library Path",@DesktopDir,"ALL(*.*)",18,"TweakUI.ini")

$NumberOfRegEntries = iniRead($LibraryPath,"Number Of Entries","Number",-1)

onloadLibrary()

MainGUI()

EndIf

EndFunc

Func MainGUI()

;Create Main GUI

$mainGUI = GUICreate("ToyBox Tweak Interface",$mainGUIWidth,$mainGUIHeight,-1,-1)

;Menus: File Menu

$fileMenu = GUICtrlCreateMenu("&File")

$fileMenuItems[0] = GUICtrlCreateMenuItem("Neutral",$fileMenu)

GUICtrlSetOnEvent(-1,"onRegNeutral")

$fileMenuItems[0] = GUICtrlCreateMenuItem("Recommended",$fileMenu)

GUICtrlSetOnEvent(-1,"onRegRecommended")

$fileMenuItems[0] = GUICtrlCreateMenuItem("System Default",$fileMenu)

GUICtrlSetOnEvent(-1,"onRegSysDefault")

$Seperators[0] = GUICtrlCreateMenuitem("",$fileMenu) ;Seperator 1

$fileMenuItems[1] = GUICtrlCreateMenu("Registry",$FileMenu)

$fileMenuItemsSub[0] = GUICtrlCreateMenuItem("Imports",$fileMenuItems[1])

GUICtrlSetOnEvent(-1,"onRegImport")

$fileMenuItemsSub[1] = GUICtrlCreateMenuItem("Exports",$fileMenuItems[1])

GUICtrlSetOnEvent(-1,"onRegExport")

$Seperators[1] = GUICtrlCreateMenuitem("",$fileMenu) ;Seperator 2

$fileMenuItems[0] = GUICtrlCreateMenuItem("Exit",$fileMenu)

GUICtrlSetOnEvent(-1,"onExit")

;ModeMenu

$modeMenu = GUICtrlCreateMenu("&Mode")

$modeMenuItems = GUICtrlCreateMenuitem("Refresh F5",$modeMenu)

GUICtrlSetOnevent(-1,"onRefresh")

;HelpMenu

$helpMenu = GUiCtrlCreateMenu("Help")

$helpMenuItems[0] = GUICtrlCreateMenuItem("About ToyBox TweakUI",$helpMenu)

GUISetOnEvent(-1,"onAbout")

$helpMenuItems[1] = GUiCtrlCreateMenuItem("Visit ToyBox Homepage",$helpMenu)

GUISetOnEvent(-1,"onHomePage")

$Seperators[2] = GUICtrlCreateMenuitem("",$fileMenu) ;Seperator 3

$helpMenuItems[2] = GUICtrlCreateMenuItem("Help...",$helpMenu)

GUISetOnEvent(-1,"onhelp")

;Banner

$Banner = GUICtrlCreatePic(@ScriptDir & "\Graphics\ToyTweak\banner.jpg",0,5,$mainGUIWidth,($mainGUIHeight/7))

;Group

$ListGroup = GUICtrlCreateGroup("Tweaks",5,$mainGUIHeight*0.1464,$mainGUIWidth-10,($mainGUIHeight/2),-1,-1)

;ListView

$ListView = GUICtrlCreateListView("ChkBox|Category|Tweak Name ",10,$mainGUIHeight*0.1728,$mainGUIWidth-25,($mainGUIHeight/6)*3-25,-1,$LVS_EX_CHECKBOXES + $LVS_EX_FULLROWSELECT+$LVS_EX_GRIDLINES)

;CheckBox

For $i = 0 To $NumberOfRegEntries

$TweakDesc = IniRead($LibraryPath,"Descriptions","Desc"&$i,"Error: Specific section in TweakUI.ini not found")

$TweakType = IniRead($LibraryPath,"Category","Type"&$i,"Error: Specific section in TweakUI.ini not found")

$ListViewItem[$i] = GUICtrlCreateListViewItem($i &"|"&$TweakType&"|"&$TweakDesc ,$ListView)

_GUICtrlListViewSetColumnWidth($ListView,0,$LVSCW_AUTOSIZE)

_GUICtrlListViewSetColumnWidth($ListView,2,$LVSCW_AUTOSIZE)

Next

;Apply Button

$applyBtn = GUICtrlCreateButton("Apply",($mainGUIWidth/3),$mainGUIHeight*0.6570,$mainGUIWidth/3,$mainGUIHeight*0.0293,-1,-1)

GUICtrlSetonEvent(-1,"onApply")

;Label Group

$LabelGroup = GUICtrlCreateGroup("Tweak Info-",5,($mainGUIHeight*0.6794),$mainGUIWidth-10,($mainGUIHeight*0.2796),-1,-1)

$DescLabel = GUICtrlCreateEdit("",10,($mainGUIHeight*0.7143),$mainGUIWidth-25,$mainGUIHeight*0.2299,$ES_MULTILINE+$ES_READONLY,-1)

;Set Already There Reg Entries

onRefresh()

;Sort the Entries

;_GUICtrlListViewSort ($ListView,$NumberOfRegEntries,1)

;Show GUIs

GUISetState(@SW_Show,$mainGUI)

EndFunc

Func onloadLibrary() ;Loads the Definition file into Memory for easy access

For $x=0 to $NumberOfRegEntries

$RegKey[$x] = iniRead($LibraryPath,"Registry Entries","Key"&$x,-1)

$RegSub[$x] = iniRead($LibraryPath,"Registry Entries","sub"&$x,-1)

$RegType[$x] = iniRead($LibraryPath,"Registry Entries","type"&$x,-1)

$RegValue[$x] = iniRead($LibraryPath,"Registry Entries","value"&$x,-1)

$RegInfo[$x] = iniRead($LibraryPath,"Tweak Infomations","Info"&$x,-1)

$RegDefaultValue[$x] = iniRead($LibraryPath,"Default Registry","value"&$x,-1)

Next

EndFunc

Func onApply()

for $i = 0 To $NumberOfRegEntries

If _GUICtrlListViewGetCheckedState($ListView,$i)=1 Then

RegWrite($RegKey[$i],$RegSub[$i],"REG_" & $RegType[$i],$RegValue[$i])

If iniRead($LibraryPath,"Registry Entries","SecondPossible",-1) = "YES" Then

;MsgBox(0,"Tet",iniRead($LibraryPath,"Registry Entries","SecondKey"&$i,-1)&","&iniRead($LibraryPath,"Registry Entries","SecondSub"&$i,-1)&","&iniRead($LibraryPath,"Registry Entries","SecondType"&$i,-1)&","&iniRead($LibraryPath,"Registry Entries","SecondValue"&$i,-1))

RegWrite(iniRead($LibraryPath,"Registry Entries","SecondKey"&$i,-1),iniRead($LibraryPath,"Registry Entries","SecondSub"&$i,-1),"REG_" & iniRead($LibraryPath,"Registry Entries","SecondType"&$i,-1),iniRead($LibraryPath,"Registry Entries","SecondValue"&$i,-1))

EndIf

Elseif _GUICtrlListViewGetCheckedState($ListView,$i)=0 Then

If $RegDefaultValue[$i] <> "-" Then

RegWrite($RegKey[$i],$RegSub[$i],"REG_" & $RegType[$i],$RegDefaultValue[$i])

Else

RegDelete($RegKey[$i],$RegSub[$i])

EndIf

Sleep(10)

EndIf

Next

onRegNeutral()

EndFunc

Func onRegNeutral()

For $i = 0 to $NumberOfRegEntries

GUICtrlSetColor($LIstViewItem[$i],0)

Next

Sleep(100)

EndFunc

Func onRegRecommended()

Local $r_Temp = StringSplit(iniRead($LibraryPath,"Recommanded Registry","recommanded",-1),",",1)

for $r = 1 to $r_Temp[0]

if RegRead($RegKey[$r_Temp[$r]],$RegSub[$r_Temp[$r]]) = $RegValue[$r_Temp[$r]] Then

GuiCtrlsetColor($ListViewItem[$r_Temp[$r]],0x00ff00)

ElseIf RegRead($RegKey[$r_Temp[$r]],$RegSub[$r_Temp[$r]]) <> $RegValue[$r_Temp[$r]] Then

GuiCtrlsetColor($ListViewItem[$r_Temp[$r]],0xff0000)

EndIf

Next

EndFunc

Func onRegSysDefault()

Local $q_Temp = MsgBox(3,"Warning: Are You Sure?","System Registry is about to be set to default, are you sure?")

If $q_Temp = 6 Then

For $t = 0 to $NumberOfRegEntries

If $RegDefaultValue[$t] <> "-" Then

RegWrite($RegKey[$t],$RegSub[$t],"REG_" & $RegType[$t],$RegDefaultValue[$t])

Else

RegDelete($RegKey[$t],$RegSub[$t])

EndIf

Next

Else

Sleep(100)

EndIf

onRegNeutral()

EndFunc

Func onRegImport()

Local $e_Path

Local $FontSize = 13

$e_Path = FileOpenDialog("Please Choose File to Import",@HomeDrive,"Reg files (*.reg)",18,"RegistryBackup-" & @Mon & "-" & @MDAY & "-" & @Year)

Sleep(500)

If $e_Path <> "" Then

if @DesktopWidth <= 1024 Then $FontSize = 10

SplashTextOn("TweakUI: Importing Registry","TweakUI is now Importing your Registry from " & $e_Path & " Please Wait...",@DesktopWidth/4,@DesktopHeight/10,-1,-1,16,"Aerial",$FontSize,500)

Sleep(100)

runwait(@comspec & " /c " & "REGEDIT " & '"' & $e_Path & '"', "" ,@SW_Hide)

SplashOff()

else

MsgBox(16,"Warning","Action canceled by the user, no file was imported",10)

EndIf

EndFunc

Func onRegExport()

Local $e_Path

Local $FontSize = 13

$e_Path = FileSaveDialog("Please Choose Export Path",@HomeDrive,"All (*.*)|Reg files (*.reg)",18,"RegistryBackup-" & @Mon & "-" & @MDAY & "-" & @Year)

Sleep(500)

If $e_Path <> "" Then

if @DesktopWidth <= 1024 Then $FontSize = 10

SplashTextOn("TweakUI: Exporting Registry","TweakUI is now exporting your Registry to " & $e_Path & ".reg Please Wait...",@DesktopWidth/4,@DesktopHeight/10,-1,-1,16,"Aerial",$FontSize,500)

Sleep(100)

runwait(@comspec & " /c " & "REGEDIT /E " & '"' & $e_Path & '.reg"', "" ,@SW_Hide)

SplashOff()

else

MsgBox(16,"Warning","Action canceled by the user, no registry was exported",10)

EndIf

EndFunc

Func onRefresh()

onloadLibrary()

Sleep(50)

For $count = 0 to $NumberOfRegEntries

if RegRead($RegKey[$count],$RegSub[$count]) = $RegValue[$count] Then

GuiCtrlSetState($ListViewItem[$count],$GUI_CHECKED)

;GUiCtrlSetBkColor($ListViewItem[$count],0x00ff00)

Else

GuiCtrlSetState($ListViewItem[$count],$GUI_UNCHECKED)

EndIf

Next

onRegNeutral()

EndFunc

Func InfoDisplay()

Local $pos = GUIGetCursorInfo()

If ($pos[4] == $ListView) Then

If _GUICtrlListViewGetCurSel($ListView) <> -1 Then

GUICtrlSetData($DescLabel, $RegInfo[_GUICtrlListViewGetCurSel($ListView)])

EndIf

EndIf

EndFunc

Func onAbout()

;About this program and me.. nah no one cares anyways ..

EndFunc

Func onHomePage()

;Connect to HomePage .. Not done yet =P

EndFunc

Func onhelp()

;Help Goes Here

EndFunc

Func onExit()

Exit

EndFunc

***********************************************************************************

*Definition File is on the end of this post for download. This like _GUICtrlListViewSort is now comment out ok line 126, uncomment it and you will see the difference.

What is happening is I wanted the _GUICtrlListViewSort to sort the Tweak Type Colume, so it looks organized later on as i added random type of tweak in to the def file, but it cancels all the check set previously by the onRefresh() Function and everything that runs on for loop. My guess is becaused it rearranged the list and caused it not in order making my for loops useless, but i have no prove of thats wut is happening just a wild guess. Is there any way i can fix this? THanks in Advance.

Components.rar

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I find out that _GUICtrlListViewSort doesnt work with my program... here is my code.

Only works if used correctly

try the attachment

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

Only works if used correctly

try the attachment

I tried it out but still all the functions are still not working... before the change it sorts also but its a good thing to have the correct way to do it. But my question was not about it doesnt sort, it was mainly on it cancelles out my otehr functions of the program.. (description was at the buttom of my original post, sorry it was seperated from the top..a bit confusing there).

Share this post


Link to post
Share on other sites

I tried it out but still all the functions are still not working... before the change it sorts also but its a good thing to have the correct way to do it. But my question was not about it doesnt sort, it was mainly on it cancelles out my otehr functions of the program.. (description was at the buttom of my original post, sorry it was seperated from the top..a bit confusing there).

being your trying to do everything from the control Ids of the items you have 3 options

1 don't use the control ids, use index

2 look at using the new function GUICtrlRegisterListViewSort

3 don't sort

I just tested the second out, after the sort the id's are still the same.


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

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