Sign in to follow this  
Followers 0
Damein

Duplicate items coming up on GUI

5 posts in this topic

Alright, so this script is kind of long and rough at the moment. But I can't seem to figure out why I keep getting duplicate listings in the GUI.

If you run the script and click "All Movies" and then scroll through the pages everything works. But if you click "All Movies" on page 1-4 and then go to page 5, it lists page 4's movies as well as page 5.

If someone could look it over and find my flaw I'd be happy :unsure:

Here is the ini for the movies list.

(Rename it to .ini)

And here is the script

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Global $HelpMenuItem, $AboutGui, $NumberOfMovies, $IncreaseX, $IncreaseX2, $IncreaseY, $DefaultLabel, $MovieInfoGui, $MainGui, $DrawLines, $hGraphic,$CurrentMovieNumber, $PageNumber, $Increment, $MoviesUpdated

Dim $Movie[7000], $MovieGenre[7000], $MovieKidStatus[7000], $MovieLength[7000], $MovieRating[7000], $Label[7000], $Pages[7000]

Opt("GUIOnEventMode", 1)

$MovieDBIni = IniRead("Movie Database.ini","Blank","1", "Not Found")
If $MovieDBIni = "Not Found" Then
    IniWrite("Movie Database.ini", "Blank", "1", "0")
    _StartGui()
Else
    _StartGui()
EndIf

Func _StartGui()
    $MainGui = GuiCreate("Movie Database", 900,700)
    GUISetOnEvent($Gui_Event_Close, "_Quit")
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($MainGui)
    $AddMovie = GuiCtrlCreateMenu("Add/Remove Movie")
    $AddMovieItem = GuiCtrlCreateMenuItem("Add Movie", $AddMovie)
    GUICtrlSetOnEvent($AddMovieItem, "_AddNewMovie")
    $RemoveMovieItem = GuiCtrlCreateMenuItem("Remove Movie", $AddMovie)
    GUICtrlSetOnEvent($RemoveMovieItem, "_RemoveMovie")
    $HelpMenu = GuiCtrlCreateMenu("Help")
    $HelpMenuItem = GuiCtrlCreateMenuItem("Help", $HelpMenu)
    GUICtrlSetOnEvent($HelpMenuItem, "_Help")
    $HelpMenuItemAbout = GuiCtrlCreateMenuItem("About", $HelpMenu)
    GUICtrlSetOnEvent($HelpMenuItemAbout, "_About")
    $ContextMenu = GuiCtrlCreateContextMenu()
    $AddMovieToContextMenu = GuiCtrlCreateMenuItem("Add Movie", $ContextMenu)
    GUICtrlSetOnEvent($AddMovieToContextMenu, "_AddNewMovie")
    $RemoveMovieToContextMenu = GuiCtrlCreateMenuItem("Remove Movie", $ContextMenu)
    GUICtrlSetOnEvent($RemoveMovieToContextMenu, "_RemoveMovie")
    GuiCtrlCreateGroup("", 0,-4,900,40)
    GuiCtrlCreateLabel("Search",700,11)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GuiCtrlSetFont(-1,10)
    $SearchBox = GuiCtrlCreateEdit("", 750,10,120,20)
    $TreeView = GuiCtrlCreateTreeView(2,40,200,636,BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)
    $AllMovieList = GuiCtrlCreateTreeViewItem("All Movies", $TreeView)
    GUICtrlSetOnEvent($AllMovieList, "_DisplayAllMovies")
    $GenreMovieList = GuiCtrlCreateTreeViewItem("Genre's", $TreeView)
    $KidMovieList = GuiCtrlCreateTreeViewItem("Kid's Movies", $TreeView)
    $LoanedMovieList = GuiCtrlCreateTreeViewItem("Loaned Movies", $TreeView)
    $ActionMovieList = GuiCtrlCreateTreeViewItem("Action", $GenreMovieList)
    GUICtrlSetOnEvent($ActionMovieList, "_DisplayActionMovies")
    $AdventureMovieList = GuiCtrlCreateTreeViewItem("Adventure", $GenreMovieList)
    $AnimationMovieList = GuiCtrlCreateTreeViewItem("Animation", $GenreMovieList)
    $BiographyMovieList = GuiCtrlCreateTreeViewItem("Biography", $GenreMovieList)
    $ComedyMovieList = GuiCtrlCreateTreeViewItem("Comedy", $GenreMovieList)
    $CrimeMovieList = GuiCtrlCreateTreeViewItem("Crime", $GenreMovieList)
    $DocumentaryMovieList = GuiCtrlCreateTreeViewItem("Documentary", $GenreMovieList)
    $DramaMovieList = GuiCtrlCreateTreeViewItem("Drama", $GenreMovieList)
    $FamilyMovieList = GuiCtrlCreateTreeViewItem("Family", $GenreMovieList)
    $FantasyMovieList = GuiCtrlCreateTreeViewItem("Fantasy", $GenreMovieList)
    $HistoryMovieList = GuiCtrlCreateTreeViewItem("History", $GenreMovieList)
    $HorrorMovieList = GuiCtrlCreateTreeViewItem("Horror", $GenreMovieList)
    $MusicalMovieList = GuiCtrlCreateTreeViewItem("Musical", $GenreMovieList)
    $MysteryMovieList = GuiCtrlCreateTreeViewItem("Mystery", $GenreMovieList)
    $RomanceMovieList = GuiCtrlCreateTreeViewItem("Romance", $GenreMovieList)
    $SciFiMovieList = GuiCtrlCreateTreeViewItem("Sci-Fi", $GenreMovieList)
    $ThrillerMovieList = GuiCtrlCreateTreeViewItem("Thriller", $GenreMovieList)
    $WarMovieList = GuiCtrlCreateTreeViewItem("War", $GenreMovieList)
    $WesternMovieList = GuiCtrlCreateTreeViewItem("Western", $GenreMovieList)
    GuiSetState()
    _ReadDatabase()
EndFunc

Func _ReadDatabase()
        For $i = 1 To 6999 Step +1
        GuiCtrlSetData($Label[$i], "")
        Next
    $Var = IniReadSectionNames("Movie Database.ini")
    For $i = 2 To $Var[0]
        $Movie[$i] = $Var[$i]
    Next
    $NumberOfMovies = $i-1
    For $NumberOfPagesToMake = $NumberOfMovies To 0 Step -1
        $Increment += 1
        If $Increment = 30 Then
        $PageNumber += 1
        $Increment = 0
        EndIf
    Next
    For $i = 2 To 7000 Step +1
        $MovieGenre[$i] = IniRead("Movie Database.ini", $Movie[$i], "Genre", "Not found")
        If $MovieGenre[$i] = "Not Found" Then
            ExitLoop
            EndIf
    Next    
    For $i = 2 To 7000 Step +1
        $MovieKidStatus[$i] = IniRead("Movie Database.ini", $Movie[$i], "KidOrNot", "Not found")
        If $MovieKidStatus[$i] = "Not Found" Then
            ExitLoop
            EndIf
    Next    
    For $i = 2 To 7000 Step +1
        $MovieLength[$i] = IniRead("Movie Database.ini", $Movie[$i], "RunTime", "Not found")
        If $MovieLength[$i] = "Not Found" Then
            ExitLoop
            EndIf
    Next    
    For $i = 2 To 7000 Step +1
        $MovieRating[$i] = IniRead("Movie Database.ini", $Movie[$i], "Rating", "Not found")
        If $MovieRating[$i] = "Not Found" Then
            ExitLoop
            EndIf
        Next
EndFunc
    
Func _DisplayAllMovies()
    If $MoviesUpdated = 0 Then
    If $DrawLines = 0 Then
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 125, 891, 125,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 238, 891, 238,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 341, 891, 341,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 440, 891, 440,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 530, 891, 530,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 620, 891, 620,0)
        $DrawLines = 1
    EndIf
    $IncreaseX = 0
    $IncreaseY = 0
    $CurrentMovieNumber = 0
    $i = 0
        For $i = 2 To $NumberOfMovies Step +1
            If $CurrentMovieNumber = 5 Then
                $IncreaseX = 0
                $IncreaseY = 110
            EndIf
            If $CurrentMovieNumber = 10 Then
                $IncreaseX = 0
                $IncreaseY = 210
            EndIf           
            If $CurrentMovieNumber = 15 Then
                $IncreaseX = 0
                $IncreaseY = 310
            EndIf           
            If $CurrentMovieNumber = 20 Then
                $IncreaseX = 0
                $IncreaseY = 410
            EndIf           
            If $CurrentMovieNumber = 25 Then
                $IncreaseX = 0
                $IncreaseY = 510
            EndIf
            If $CurrentMovieNumber = 30 Then
                $IncreaseY = 0
                $IncreaseX = 0
                $CurrentMovieNumber = 0
            EndIf
            $Label[$i] = GuiCtrlCreateLabel($Movie[$i], 230+$IncreaseX, 60+$IncreaseY,80,50,$SS_Center)
            GUICtrlSetOnEvent($Label[$i], "_DisplayMovieInfo")
            GuiCtrlSetState($Label[$i], $GUI_HIDE)
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 140
            $CurrentMovieNumber += 1
        Next
        $IncreaseX = 0
        For $i = 1 To $PageNumber+1 Step +1
            $Pages[$i] = GuiCtrlCreateLabel($i, 500+$IncreaseX, 645,20,50,$SS_Center)
            GUICtrlSetOnEvent($Pages[$i], "_DisplayPage")
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 20
        Next
        $MoviesUpdates = 1
    Else
        Sleep(100)
        EndIf
    EndFunc
    
Func _DisplayActionMovies()
    If $DrawLines = 0 Then
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 125, 891, 125,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 238, 891, 238,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 341, 891, 341,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 440, 891, 440,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 530, 891, 530,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 620, 891, 620,0)
        $DrawLines = 1
    EndIf
    $IncreaseX = 0
    $IncreaseX2 = 0
    $IncreaseY = 0
        For $i = 2 To $NumberOfMovies Step +1
            If $CurrentMovieNumber = 5 Then
                $IncreaseX = 00
                $IncreaseY = 110
            EndIf
            If $CurrentMovieNumber = 10 Then
                $IncreaseX = 00
                $IncreaseY = 210
            EndIf           
            If $CurrentMovieNumber = 15 Then
                $IncreaseX = 00
                $IncreaseY = 310
            EndIf           
            If $CurrentMovieNumber = 20 Then
                $IncreaseX = 00
                $IncreaseY = 410
            EndIf           
            If $CurrentMovieNumber = 25 Then
                $IncreaseX = 00
                $IncreaseY = 510
            EndIf
            If $CurrentMovieNumber = 30 Then
                $IncreaseY = 0
                $IncreaseX = 0
                $CurrentMovieNumber = 0
            EndIf
            $MovieGenre = IniRead("Movie Database.ini", $Movie[$i], "Genre", "Not Found")
            If $MovieGenre = "Action" Then
            $Label[$i] = GuiCtrlCreateLabel($Movie[$i], 230+$IncreaseX, 60+$IncreaseY,80,50,$SS_Center)
            GUICtrlSetOnEvent($Label[$i], "_DisplayMovieInfo")
            GuiCtrlSetState($Label[$i], $GUI_HIDE)
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 140
            $CurrentMovieNumber += 1
            EndIf
        Next
        $IncreaseX = 0
        For $i = 1 To $PageNumber+1 Step +1
            $Pages[$i] = GuiCtrlCreateLabel($i, 500+$IncreaseX, 645,20,50,$SS_Center)
            GUICtrlSetOnEvent($Pages[$i], "_DisplayPage")
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 20
        Next
        _DisplayPage()
        EndFunc
    
Func _AddNewMovie()
    $MoviesUpdated = 0
    $NameOfMovie = InputBox("Name","Please enter the name of the new entry.")
    If StringLen($NameOfMovie) > 36 Then
        MsgBox(48,"Error!", "If the number of characters (Spaces, letters etc.) exceed 36 then the title will not show properly. Please attempt to abbreviate or reduce the number of characters in the title of the movie.")
        $NameOfMovie = InputBox("Name", "Please enter the name of the new entry.")
        EndIf
    $ReadNameToVerifyNoDuplicate = IniReadSection("Movie Database.ini", $NameOfMovie)
    If @error Then
        $GenreOfMovie = InputBox("Genre", "Please enter the genre of the new entry.")
        $KidOrNot = InputBox("Kid Movie?", "Please enter if movie is a kid's movie or not. (Y or N)")
        $RunTime = InputBox("Run Length", "Please enter the length of the new entry.")
        $Rating = InputBox("Rating", "Please enter the rating of the new entry (PG, R, etc.)")
        IniWrite("Movie Database.ini", $NameOfMovie, "Genre", $GenreOfMovie)
        IniWrite("Movie Database.ini", $NameOfMovie, "KidOrNot", $KidOrNot)
        IniWrite("Movie Database.ini", $NameOfMovie, "RunTime", $RunTime)
        IniWrite("Movie Database.ini", $NameOfMovie, "Rating", $Rating)
    Else
        MsgBox(48, "Error","Duplicate movie located!")
    EndIf
    _ReadDatabase()
EndFunc

Func _RemoveMovie()
    $MoviesUpdated = 0
    $NameOfMovieToRemove = InputBox("Name", "Please enter the name of the movie you would like to remove.")
    IniDelete("Movie Database.ini", $NameOfMovieToRemove)
    MsgBox(0, "Movie Removed", "The movie: " & $NameOfMovieToRemove & " has been removed.")
EndFunc

Func _DisplayMovieInfo()
    $DisplayMovieInfo = GuiCtrlRead(@GUI_CTRLID)
            $GenreInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "Genre", "Not Found")
            $KidOrNotInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "KidOrNot", "Not Found")
            $RunTimeInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "RunTime", "Not Found")
            $RatingInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "Rating", "Not Found")
            $MovieInfoGui = GuiCreate($DisplayMovieInfo, 400,300)
            GUISetOnEvent($Gui_Event_Close, "_Quit")
            GuiCtrlCreateGroup("",10,35,380,50)
            GuiCtrlCreateLabel("Genre",0,20,400,20,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($GenreInfo,0,55,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiCtrlCreateGroup("",10,100,380,50)
            GuiCtrlCreateLabel("Kid movie?",0,85,400,20,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($KidOrNotInfo,0,120,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiCtrlCreateGroup("",10,165,380,50)
            GuiCtrlCreateLabel("Run time",0,150,400,20,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($RunTimeInfo,0,185,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiCtrlCreateGroup("",10,235,380,50)
            GuiCtrlCreateLabel("Rating",0,215,400,22,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($RatingInfo,0,250,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiSetState()
EndFunc

Func _Help()
    MsgBox(0, "Test", "Help")
EndFunc

Func _About()
    $AboutGui = GuiCreate("About", 300,130)
    GUISetOnEvent($Gui_Event_Close, "_Quit")
    GuiCtrlCreatePic("Data\R.S.Software.jpg",10,5,280,90)
    GuiCtrlCreateLabel("© R.S. Software - 2011", 60,100,300,15)
    GuiCtrlSetFont(-1,13)
    $WebsiteLink = GuiCtrlCreateLabel("Http://rssoftware.webs.com", 80,115,300,120)
    GUICtrlSetOnEvent($WebsiteLink, "_OpenWebsite")
    GuiCtrlSetFont(-1,8,2)
    GUICtrlSetColor ($WebsiteLink, 0x3399FF)
    GuiSetState()
EndFunc

Func _OpenWebsite()
    ;RunWebsite: Http://rssoftware.webs.com
    MsgBox(0, "Test", "Test")
EndFunc

Func _Quit()
    If @GUI_WINHANDLE = $AboutGui Then
        GuiDelete($AboutGui)
    ElseIf @Gui_WinHandle = $MovieInfoGui Then
        GuiDelete($MovieInfoGui)
    ElseIf @Gui_WinHandle = $MainGui Then
    Exit
    EndIf
EndFunc

Func _DisplayPage()
    $DisplayPage = GuiCtrlRead(@GUI_CTRLID)
    If $DisplayPage = 1 Then
    For $i = 2 To 32 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next
    For $i = 32 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
ElseIf $DisplayPage = 2 Then
    For $i = 2 To 32 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    For $i = 32 To 62 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 62 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
ElseIf $DisplayPage = 3 Then
    For $i = 2 To 62 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 62 To 92 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 92 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
ElseIf $DisplayPage = 4 Then
    For $i = 2 To 92 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 92 To 122 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 122 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    ElseIf $DisplayPage = 5 Then
    For $i = 2 To 122 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 122 To 152 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 152 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    ElseIf $DisplayPage = 6 Then
    For $i = 2 To 152 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 152 To 182 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 182 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
ElseIf $DisplayPage = 7 Then
    For $i = 2 To 182 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 182 To 212 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 212 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    ElseIf $DisplayPage = 8 Then
    For $i = 2 To 212 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 212 To 242 Step +1
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 242 To 6999 Step +1
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    EndIf
EndFunc

While 1
    Sleep(10)
WEnd

Also, if you know of a better way to do the pages, that would probably fix my problem/help me out, so feel free :>

Thanks!


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites



Damein

This looks like the start of something good:}

I removed all step +1

your code should look like this

For $i = 2 To 7000
        $MovieGenre[$i] = IniRead("Movie Database.ini", $Movie[$i], "Genre", "Not found")
        If $MovieGenre[$i] = "Not Found" Then
            ExitLoop
            EndIf
    Next
    For $i = 2 To 7000
        $MovieKidStatus[$i] = IniRead("Movie Database.ini", $Movie[$i], "KidOrNot", "Not found")
        If $MovieKidStatus[$i] = "Not Found" Then
            ExitLoop
            EndIf

Except this line 85 you will need this Step -1

For $NumberOfPagesToMake = $NumberOfMovies To 0 Step -1

After I removed all the step +1 from your script, I got it to work without the duplicates.

Give it a shot and see if you get the same results:]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Step +1 is the default anyway and never needs to be specified.

EDIT: Actually the default is Step 1 not Step +1

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Actually, no, I don't get the same result, lol.

Removing all the steps yields the same results as before (As I assume it should, since it was happening either way)

Try running the program > clicking all movies > page 4 > all movies > page 5.

Doing this has page 5+4 on the GUI.

Here is the code I was using:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Global $HelpMenuItem, $AboutGui, $NumberOfMovies, $IncreaseX, $IncreaseX2, $IncreaseY, $DefaultLabel, $MovieInfoGui, $MainGui, $DrawLines, $hGraphic,$CurrentMovieNumber, $PageNumber, $Increment, $MoviesUpdated

Dim $Movie[7000], $MovieGenre[7000], $MovieKidStatus[7000], $MovieLength[7000], $MovieRating[7000], $Label[7000], $Pages[7000]

Opt("GUIOnEventMode", 1)

$MovieDBIni = IniRead("Movie Database.ini","Blank","1", "Not Found")
If $MovieDBIni = "Not Found" Then
    IniWrite("Movie Database.ini", "Blank", "1", "0")
    _StartGui()
Else
    _StartGui()
EndIf

Func _StartGui()
    $MainGui = GuiCreate("Movie Database", 900,700)
    GUISetOnEvent($Gui_Event_Close, "_Quit")
    _GDIPlus_Startup ()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($MainGui)
    $AddMovie = GuiCtrlCreateMenu("Add/Remove Movie")
    $AddMovieItem = GuiCtrlCreateMenuItem("Add Movie", $AddMovie)
    GUICtrlSetOnEvent($AddMovieItem, "_AddNewMovie")
    $RemoveMovieItem = GuiCtrlCreateMenuItem("Remove Movie", $AddMovie)
    GUICtrlSetOnEvent($RemoveMovieItem, "_RemoveMovie")
    $HelpMenu = GuiCtrlCreateMenu("Help")
    $HelpMenuItem = GuiCtrlCreateMenuItem("Help", $HelpMenu)
    GUICtrlSetOnEvent($HelpMenuItem, "_Help")
    $HelpMenuItemAbout = GuiCtrlCreateMenuItem("About", $HelpMenu)
    GUICtrlSetOnEvent($HelpMenuItemAbout, "_About")
    $ContextMenu = GuiCtrlCreateContextMenu()
    $AddMovieToContextMenu = GuiCtrlCreateMenuItem("Add Movie", $ContextMenu)
    GUICtrlSetOnEvent($AddMovieToContextMenu, "_AddNewMovie")
    $RemoveMovieToContextMenu = GuiCtrlCreateMenuItem("Remove Movie", $ContextMenu)
    GUICtrlSetOnEvent($RemoveMovieToContextMenu, "_RemoveMovie")
    GuiCtrlCreateGroup("", 0,-4,900,40)
    GuiCtrlCreateLabel("Search",700,11)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GuiCtrlSetFont(-1,10)
    $SearchBox = GuiCtrlCreateEdit("", 750,10,120,20)
    $TreeView = GuiCtrlCreateTreeView(2,40,200,636,BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)
    $AllMovieList = GuiCtrlCreateTreeViewItem("All Movies", $TreeView)
    GUICtrlSetOnEvent($AllMovieList, "_DisplayAllMovies")
    $GenreMovieList = GuiCtrlCreateTreeViewItem("Genre's", $TreeView)
    $KidMovieList = GuiCtrlCreateTreeViewItem("Kid's Movies", $TreeView)
    $LoanedMovieList = GuiCtrlCreateTreeViewItem("Loaned Movies", $TreeView)
    $ActionMovieList = GuiCtrlCreateTreeViewItem("Action", $GenreMovieList)
    GUICtrlSetOnEvent($ActionMovieList, "_DisplayActionMovies")
    $AdventureMovieList = GuiCtrlCreateTreeViewItem("Adventure", $GenreMovieList)
    $AnimationMovieList = GuiCtrlCreateTreeViewItem("Animation", $GenreMovieList)
    $BiographyMovieList = GuiCtrlCreateTreeViewItem("Biography", $GenreMovieList)
    $ComedyMovieList = GuiCtrlCreateTreeViewItem("Comedy", $GenreMovieList)
    $CrimeMovieList = GuiCtrlCreateTreeViewItem("Crime", $GenreMovieList)
    $DocumentaryMovieList = GuiCtrlCreateTreeViewItem("Documentary", $GenreMovieList)
    $DramaMovieList = GuiCtrlCreateTreeViewItem("Drama", $GenreMovieList)
    $FamilyMovieList = GuiCtrlCreateTreeViewItem("Family", $GenreMovieList)
    $FantasyMovieList = GuiCtrlCreateTreeViewItem("Fantasy", $GenreMovieList)
    $HistoryMovieList = GuiCtrlCreateTreeViewItem("History", $GenreMovieList)
    $HorrorMovieList = GuiCtrlCreateTreeViewItem("Horror", $GenreMovieList)
    $MusicalMovieList = GuiCtrlCreateTreeViewItem("Musical", $GenreMovieList)
    $MysteryMovieList = GuiCtrlCreateTreeViewItem("Mystery", $GenreMovieList)
    $RomanceMovieList = GuiCtrlCreateTreeViewItem("Romance", $GenreMovieList)
    $SciFiMovieList = GuiCtrlCreateTreeViewItem("Sci-Fi", $GenreMovieList)
    $ThrillerMovieList = GuiCtrlCreateTreeViewItem("Thriller", $GenreMovieList)
    $WarMovieList = GuiCtrlCreateTreeViewItem("War", $GenreMovieList)
    $WesternMovieList = GuiCtrlCreateTreeViewItem("Western", $GenreMovieList)
    GuiSetState()
    _ReadDatabase()
EndFunc

Func _ReadDatabase()
        For $i = 1 To 6999
        GuiCtrlSetData($Label[$i], "")
        Next
    $Var = IniReadSectionNames("Movie Database.ini")
    For $i = 2 To $Var[0]
        $Movie[$i] = $Var[$i]
    Next
    $NumberOfMovies = $i-1
    For $NumberOfPagesToMake = $NumberOfMovies To 0 Step -1
        $Increment += 1
        If $Increment = 30 Then
        $PageNumber += 1
        $Increment = 0
        EndIf
    Next
    For $i = 2 To 7000
        $MovieGenre[$i] = IniRead("Movie Database.ini", $Movie[$i], "Genre", "Not found")
        If $MovieGenre[$i] = "Not Found" Then
            ExitLoop
            EndIf
    Next    
    For $i = 2 To 7000
        $MovieKidStatus[$i] = IniRead("Movie Database.ini", $Movie[$i], "KidOrNot", "Not found")
        If $MovieKidStatus[$i] = "Not Found" Then
            ExitLoop
            EndIf
    Next    
    For $i = 2 To 7000
        $MovieLength[$i] = IniRead("Movie Database.ini", $Movie[$i], "RunTime", "Not found")
        If $MovieLength[$i] = "Not Found" Then
            ExitLoop
            EndIf
    Next    
    For $i = 2 To 7000
        $MovieRating[$i] = IniRead("Movie Database.ini", $Movie[$i], "Rating", "Not found")
        If $MovieRating[$i] = "Not Found" Then
            ExitLoop
            EndIf
        Next
EndFunc
    
Func _DisplayAllMovies()
    If $MoviesUpdated = 0 Then
    If $DrawLines = 0 Then
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 125, 891, 125,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 238, 891, 238,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 341, 891, 341,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 440, 891, 440,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 530, 891, 530,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 620, 891, 620,0)
        $DrawLines = 1
    EndIf
    $IncreaseX = 0
    $IncreaseY = 0
    $CurrentMovieNumber = 0
    $i = 0
        For $i = 2 To $NumberOfMovies
            If $CurrentMovieNumber = 5 Then
                $IncreaseX = 0
                $IncreaseY = 110
            EndIf
            If $CurrentMovieNumber = 10 Then
                $IncreaseX = 0
                $IncreaseY = 210
            EndIf           
            If $CurrentMovieNumber = 15 Then
                $IncreaseX = 0
                $IncreaseY = 310
            EndIf           
            If $CurrentMovieNumber = 20 Then
                $IncreaseX = 0
                $IncreaseY = 410
            EndIf           
            If $CurrentMovieNumber = 25 Then
                $IncreaseX = 0
                $IncreaseY = 510
            EndIf
            If $CurrentMovieNumber = 30 Then
                $IncreaseY = 0
                $IncreaseX = 0
                $CurrentMovieNumber = 0
            EndIf
            $Label[$i] = GuiCtrlCreateLabel($Movie[$i], 230+$IncreaseX, 60+$IncreaseY,80,50,$SS_Center)
            GUICtrlSetOnEvent($Label[$i], "_DisplayMovieInfo")
            GuiCtrlSetState($Label[$i], $GUI_HIDE)
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 140
            $CurrentMovieNumber += 1
        Next
        $IncreaseX = 0
        For $i = 1 To $PageNumber+1
            $Pages[$i] = GuiCtrlCreateLabel($i, 500+$IncreaseX, 645,20,50,$SS_Center)
            GUICtrlSetOnEvent($Pages[$i], "_DisplayPage")
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 20
        Next
        $MoviesUpdates = 1
    Else
        Sleep(100)
        EndIf
    EndFunc
    
Func _DisplayActionMovies()
    If $DrawLines = 0 Then
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 125, 891, 125,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 238, 891, 238,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 341, 891, 341,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 440, 891, 440,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 530, 891, 530,0)
        _GDIPlus_GraphicsDrawLine ($hGraphic, 209, 620, 891, 620,0)
        $DrawLines = 1
    EndIf
    $IncreaseX = 0
    $IncreaseX2 = 0
    $IncreaseY = 0
        For $i = 2 To $NumberOfMovies
            If $CurrentMovieNumber = 5 Then
                $IncreaseX = 00
                $IncreaseY = 110
            EndIf
            If $CurrentMovieNumber = 10 Then
                $IncreaseX = 00
                $IncreaseY = 210
            EndIf           
            If $CurrentMovieNumber = 15 Then
                $IncreaseX = 00
                $IncreaseY = 310
            EndIf           
            If $CurrentMovieNumber = 20 Then
                $IncreaseX = 00
                $IncreaseY = 410
            EndIf           
            If $CurrentMovieNumber = 25 Then
                $IncreaseX = 00
                $IncreaseY = 510
            EndIf
            If $CurrentMovieNumber = 30 Then
                $IncreaseY = 0
                $IncreaseX = 0
                $CurrentMovieNumber = 0
            EndIf
            $MovieGenre = IniRead("Movie Database.ini", $Movie[$i], "Genre", "Not Found")
            If $MovieGenre = "Action" Then
            $Label[$i] = GuiCtrlCreateLabel($Movie[$i], 230+$IncreaseX, 60+$IncreaseY,80,50,$SS_Center)
            GUICtrlSetOnEvent($Label[$i], "_DisplayMovieInfo")
            GuiCtrlSetState($Label[$i], $GUI_HIDE)
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 140
            $CurrentMovieNumber += 1
            EndIf
        Next
        $IncreaseX = 0
        For $i = 1 To $PageNumber+1 Step
            $Pages[$i] = GuiCtrlCreateLabel($i, 500+$IncreaseX, 645,20,50,$SS_Center)
            GUICtrlSetOnEvent($Pages[$i], "_DisplayPage")
            GuiCtrlSetFont(-1, 10)
            GUICtrlSetColor(-1, 0x3399FF)
            $IncreaseX += 20
        Next
        _DisplayPage()
        EndFunc
    
Func _AddNewMovie()
    $MoviesUpdated = 0
    $NameOfMovie = InputBox("Name","Please enter the name of the new entry.")
    If StringLen($NameOfMovie) > 36 Then
        MsgBox(48,"Error!", "If the number of characters (Spaces, letters etc.) exceed 36 then the title will not show properly. Please attempt to abbreviate or reduce the number of characters in the title of the movie.")
        $NameOfMovie = InputBox("Name", "Please enter the name of the new entry.")
        EndIf
    $ReadNameToVerifyNoDuplicate = IniReadSection("Movie Database.ini", $NameOfMovie)
    If @error Then
        $GenreOfMovie = InputBox("Genre", "Please enter the genre of the new entry.")
        $KidOrNot = InputBox("Kid Movie?", "Please enter if movie is a kid's movie or not. (Y or N)")
        $RunTime = InputBox("Run Length", "Please enter the length of the new entry.")
        $Rating = InputBox("Rating", "Please enter the rating of the new entry (PG, R, etc.)")
        IniWrite("Movie Database.ini", $NameOfMovie, "Genre", $GenreOfMovie)
        IniWrite("Movie Database.ini", $NameOfMovie, "KidOrNot", $KidOrNot)
        IniWrite("Movie Database.ini", $NameOfMovie, "RunTime", $RunTime)
        IniWrite("Movie Database.ini", $NameOfMovie, "Rating", $Rating)
    Else
        MsgBox(48, "Error","Duplicate movie located!")
    EndIf
    _ReadDatabase()
EndFunc

Func _RemoveMovie()
    $MoviesUpdated = 0
    $NameOfMovieToRemove = InputBox("Name", "Please enter the name of the movie you would like to remove.")
    IniDelete("Movie Database.ini", $NameOfMovieToRemove)
    MsgBox(0, "Movie Removed", "The movie: " & $NameOfMovieToRemove & " has been removed.")
EndFunc

Func _DisplayMovieInfo()
    $DisplayMovieInfo = GuiCtrlRead(@GUI_CTRLID)
            $GenreInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "Genre", "Not Found")
            $KidOrNotInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "KidOrNot", "Not Found")
            $RunTimeInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "RunTime", "Not Found")
            $RatingInfo = IniRead("Movie Database.ini", $DisplayMovieInfo, "Rating", "Not Found")
            $MovieInfoGui = GuiCreate($DisplayMovieInfo, 400,300)
            GUISetOnEvent($Gui_Event_Close, "_Quit")
            GuiCtrlCreateGroup("",10,35,380,50)
            GuiCtrlCreateLabel("Genre",0,20,400,20,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($GenreInfo,0,55,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiCtrlCreateGroup("",10,100,380,50)
            GuiCtrlCreateLabel("Kid movie?",0,85,400,20,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($KidOrNotInfo,0,120,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiCtrlCreateGroup("",10,165,380,50)
            GuiCtrlCreateLabel("Run time",0,150,400,20,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($RunTimeInfo,0,185,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiCtrlCreateGroup("",10,235,380,50)
            GuiCtrlCreateLabel("Rating",0,215,400,22,$SS_CENTER)
            GuiCtrlSetFont(-1, 14)
            GuiCtrlCreateLabel($RatingInfo,0,250,400,20,$SS_CENTER)
            GUICtrlSetColor(-1, 0x3399FF)
            GuiCtrlSetFont(-1, 12)
            GuiCtrlCreateGroup("",-99,-99,1,1)
            GuiSetState()
EndFunc

Func _Help()
    MsgBox(0, "Test", "Help")
EndFunc

Func _About()
    $AboutGui = GuiCreate("About", 300,130)
    GUISetOnEvent($Gui_Event_Close, "_Quit")
    GuiCtrlCreatePic("Data\R.S.Software.jpg",10,5,280,90)
    GuiCtrlCreateLabel("© R.S. Software - 2011", 60,100,300,15)
    GuiCtrlSetFont(-1,13)
    $WebsiteLink = GuiCtrlCreateLabel("Http://rssoftware.webs.com", 80,115,300,120)
    GUICtrlSetOnEvent($WebsiteLink, "_OpenWebsite")
    GuiCtrlSetFont(-1,8,2)
    GUICtrlSetColor ($WebsiteLink, 0x3399FF)
    GuiSetState()
EndFunc

Func _OpenWebsite()
    ;RunWebsite: Http://rssoftware.webs.com
    MsgBox(0, "Test", "Test")
EndFunc

Func _Quit()
    If @GUI_WINHANDLE = $AboutGui Then
        GuiDelete($AboutGui)
    ElseIf @Gui_WinHandle = $MovieInfoGui Then
        GuiDelete($MovieInfoGui)
    ElseIf @Gui_WinHandle = $MainGui Then
    Exit
    EndIf
EndFunc

Func _DisplayPage()
    $DisplayPage = GuiCtrlRead(@GUI_CTRLID)
    If $DisplayPage = 1 Then
    For $i = 2 To 32
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next
    For $i = 32 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
ElseIf $DisplayPage = 2 Then
    For $i = 2 To 32
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    For $i = 32 To 62
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 62 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
ElseIf $DisplayPage = 3 Then
    For $i = 2 To 62
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 62 To 92
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 92 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
ElseIf $DisplayPage = 4 Then
    For $i = 2 To 92
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 92 To 122
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 122 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    ElseIf $DisplayPage = 5 Then
    For $i = 2 To 122
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 122 To 152
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 152 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    ElseIf $DisplayPage = 6 Then
    For $i = 2 To 152
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 152 To 182
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 182 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
ElseIf $DisplayPage = 7 Then
    For $i = 2 To 182
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 182 To 212
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 212 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    ElseIf $DisplayPage = 8 Then
    For $i = 2 To 212
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next    
    For $i = 212 To 242
        GuiCtrlSetState($Label[$i], $GUI_SHOW)
    Next    
    For $i = 242 To 6999
        GuiCtrlSetState($Label[$i], $GUI_HIDE)
    Next
    EndIf
EndFunc

While 1
    Sleep(10)
WEnd

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites

*bump bump*

Any other ideas? I'm still stumped at this :unsure:


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: 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