JSThePatriot Posted June 2, 2006 Share Posted June 2, 2006 @gafrost I just found your GUIListView.au3. I had never used List Views until now. I was thinking as I had to create some UDF's to delete items from a dynamically create list view that we needed something in the helpfile (extra examples) to show how to do this. @anyone My problem is I can create the initial values for a listview, but when it comes time to update (as in remove from) I can only get any of the solutions half working. If there are more to add to the list view that isnt that hard, but when one is removed and I try to "refresh" it it doesnt work very well at all. Below is my code, its 640 lines long so becareful. I havent written a program this long in a while. I will need to go back through and optimize some things. I have tried a couple of ways to get these updates as I need them to be. _RefreshYears() is how I was doing it before I found the GUIListView, and _FindFiles() is how I have been trying to do it after finding GUIListView. expandcollapse popup;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Filename: ClosedFiles.au3 (Compiled as CloseFiles.exe) ;Used With: CFOptions.exe; CFOptions.ini ;Created by: Jarvis J Stubblefield (support "at" vortexrevolutions "dot" com) ;Created on: 05/16/2006 ;Modified on: ;Modified by: ;Used for: Setting options in ClosedFiles.exe such as startup folder, move ; file vs copy file, etc... ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Preprocessor ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #include <GUIConstants.au3> #include <GUIListView.au3> #include "SQLite.au3" Opt("GUIOnEventMode", 1) ;Set GUI to ONEvent Mode. ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** File Installations ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< If Not(FileExists("sqlite3.dll")) Then FileInstall("sqlite3.dll", @ScriptDir & "sqlite3.dll") EndIf ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** SQL Initiation ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _SQLite_Startup("sqlite3.dll") If @error = $SQLITE_ERROR Then MsgBox(0, "", "Error loading SQLite.dll") _TerminateApp() EndIf _SQLite_Open("fif.db") If @error > 0 Then MsgBox(0, "ERROR", "Error loading Database") _TerminateApp() EndIf ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Registry Information ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Declare Variables ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Global $wHeight, $wWidth, $m_HWnd ;Window variables Global $wTitle ;Window variables II Global Const $g_Dir = "C:\closed files\" ;File Directory Global $bFile, $bYear, $bSearch ;Boolean File and Year to determine whether or not it has been initiated Global $File, $Year ;File and Year Variables for ListViewItem ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Define Variables ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $wHeight = 300 $wWidth = 300 $wTitle = "File-Index-Find" $bFile = 0 $bYear = 0 $bSearch = 0 ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** GUI Creation ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $m_HWnd = GUICreate($wTitle, $wWidth, $wHeight) $m_Options = GUICtrlCreateButton("Options", 5, ($wHeight - 25), 94, 20) $m_Help = GUICtrlCreateButton("Help", 103, ($wHeight - 25), 94, 20) $m_Exit = GUICtrlCreateButton("Exit", 201, ($wHeight - 25), 94, 20) ;=-=-=-=-=-=-=-=-=-= ;Start Tab Control ;=-=-=-=-=-=-=-=-=-= $m_Tab = GUICtrlCreateTab(5, 5, ($wWidth - 8), ($wHeight - 35)) ;=-=-=-=-=-=-=-=-=-= ;Create Rename Tab ;=-=-=-=-=-=-=-=-=-= $renTab = GUICtrlCreateTabItem("Rename/Move") ;ren_File List $ren_File = GUICtrlCreateListView("File ", 10, 45, 150, 150) ;ren_Folder List $ren_Folder = GUICtrlCreateGroup("Folder", 165, 45, 123, 75) $ren_FolRE = GUICtrlCreateRadio("Real Estate", 170, 60, 115, 15) $ren_FolPM = GUICtrlCreateRadio("Property Management", 170, 80, 115, 15) $ren_FolMC = GUICtrlCreateRadio("Miscellaneous", 170, 100, 115, 15) GUICtrlCreateGroup ("",-99,-99,1,1) ;close group GUICtrlSetFont($ren_FolRE, 7) GUICtrlSetFont($ren_FolPM, 7) GUICtrlSetFont($ren_FolMC, 7) ;ren_Year List $ren_Year = GUICtrlCreateListView("Year ", 165, 120, 123, 75) ;ren_File Rename $ren_RenLabel = GUICtrlCreateLabel("New Filename:", 10, 200, 75, 15) $ren_RenFile = GUICtrlCreateInput("Seller-Buyer.pdf", 85, 200, 203, 15) ;ren_Horizontal Rule (thin dark label) GUICtrlCreateLabel("", 10, 232, 280, 1) GUICtrlSetBkColor(-1, 0x666666) ;ren_Tab Buttons $ren_Refresh = GUICtrlCreateButton("Refresh Files", 10, 248, 75, 15) $ren_Remove = GUICtrlCreateButton("Remove File", 90, 248, 75, 15) $ren_Preview = GUICtrlCreateButton("Preview", 170, 248, 57, 15) GUICtrlSetState($ren_Preview, $GUI_DISABLE) $ren_Rename = GUICtrlCreateButton("Rename", 232, 248, 58, 15) _RefreshFiles() ;=-=-=-=-=-=-=-=-=-= ;Create Save Tab ;=-=-=-=-=-=-=-=-=-= $savTab = GUiCtrlCreateTabItem("Save File") $sav_Instruct = GUICtrlCreateLabel("Please fill in ALL of the fields listed. These fields are to help in the indexing of the file for searchability later.", 10, 32, 280, 30) GUICtrlSetBkColor(-1, 0xE5E5E5) ;sav_Seller $sav_SellLBL = GUICtrlCreateLabel("Seller", 10, 70, 27, 12) $sav_Seller = GUICtrlCreateInput("", 40, 70, 105, 15) ;sav_Buyer $sav_BuyLBL = GUICtrlCreateLabel("Buyer", 155, 70, 27, 13) $sav_Buyer = GUICtrlCreateInput("", 185, 70, 105, 15) ;sav_Listing Agent $sav_ListSLBL = GUICtrlCreateLabel("Listing Agent", 10, 90, 75, 13) $sav_ListAgent = GUICtrlCreateInput("", 10, 107, 137, 15) ;sav_Selling Agent $sav_SellALBL = GUICtrlCreateLabel("Selling Agent", 153, 90, 75, 13) $sav_SellAgent = GUICtrlCreateInput("", 153, 107, 137, 15) ;sav_Property Address $sav_PropLBL = GUICtrlCreateLabel("Property Address", 10, 127, 80, 13) $sav_PropAddy = GUICtrlCreateInput("", 95, 127, 195, 15) ;sav_Closing Date $sav_CloseLBL = GUICtrlCreateLabel("Closing Date", 10, 150, 60, 13) $sav_CloseDate = GUICtrlCreateDate(@MON & "/" & @MDAY & "/" & @YEAR, 75, 148, 85, 17, "MM/DD/YYYY") ;sav_Price $sav_PriceLBL = GUICtrlCreateLabel("Price", 165, 150, 25, 13) $sav_Price = GUICtrlCreateInput("", 195, 148, 95, 17) ;sav_Horizontal Rule (thin dark label) GUICtrlCreateLabel("", 10, 175, 280, 1) GUICtrlSetBkColor(-1, 0x666666) ;sav_Path $sav_PathLBL = GUICtrlCreateLabel("Path", 10, 185, 25, 13) $sav_Path = GUICtrlCreateInput("", 35, 185, 195, 15) ;sav_Filename $sav_FileLBL = GUICtrlCreateLabel("Filename", 10, 209, 45, 13) $sav_File = GUICtrlCreateInput("", 55, 209, 175, 15) ;sav_Browse Button $sav_Browse = GUICtrlCreateButton("Browse", 235, 185, 55, 40) ;sav_Horizontal Rule (thin dark label) GUICtrlCreateLabel("", 10, 234, 280, 1) GUICtrlSetBkColor(-1, 0x666666) ;sav_Save Button $sav_Save = GUICtrlCreateButton("Save Indexing Information", 10, 244, 280, 15) ;=-=-=-=-=-=-=-=-=-= ;Create Find Tab ;=-=-=-=-=-=-=-=-=-= $finTab = GUICtrlCreateTabItem("Find File") $fin_Instruct = GUICtrlCreateLabel("Please fill in as much information as possible to limit the amount of returned files.", 10, 32, 280, 30) GUICtrlSetBkColor(-1, 0xE5E5E5) ;fin_Seller $fin_SellLBL = GUICtrlCreateLabel("Seller", 10, 70, 27, 12) $fin_Seller = GUICtrlCreateInput("", 40, 70, 105, 15) ;fin_Buyer $fin_BuyLBL = GUICtrlCreateLabel("Buyer", 155, 70, 27, 13) $fin_Buyer = GUICtrlCreateInput("", 185, 70, 105, 15) ;fin_Listing Agent $fin_ListSLBL = GUICtrlCreateLabel("Listing Agent", 10, 90, 75, 13) $fin_ListAgent = GUICtrlCreateInput("", 10, 107, 137, 15) ;fin_Selling Agent $fin_SellALBL = GUICtrlCreateLabel("Selling Agent", 153, 90, 75, 13) $fin_SellAgent = GUICtrlCreateInput("", 153, 107, 137, 15) ;fin_Property Address $fin_PropLBL = GUICtrlCreateLabel("Property Address", 10, 127, 80, 13) $fin_PropAddy = GUICtrlCreateInput("", 95, 127, 195, 15) ;fin_Closing Date Range $fin_CloseLBL = GUICtrlCreateLabel("Closing Date Range", 10, 150, 85, 13) $fin_CFromLBL = GUICtrlCreateLabel("From", 10, 170, 25, 13) $fin_CFromDate = GUICtrlCreateInput("", 40, 168, 95, 17) $fin_CToLBL = GUICtrlCreateLabel("To", 140, 170, 15, 13) $fin_CToDate = GUICtrlCreateInput("", 160, 168, 95, 17) ;fin_Price Range $fin_PriceLBL = GUICtrlCreateLabel("Price Range", 10, 190, 65, 13) $fin_PFromLBL = GUICtrlCreateLabel("From", 10, 208, 25, 13) $fin_PFrom = GUICtrlCreateInput("", 40, 206, 95, 17) $fin_PToLBL = GUICtrlCreateLabel("To", 140, 208, 15, 13) $fin_PTo = GUICtrlCreateInput("", 160, 206, 95, 17) ;fin_Horizontal Rule (thin dark label) GUICtrlCreateLabel("", 10, 233, 280, 1) GUICtrlSetBkColor(-1, 0x666666) ;fin_Find Button $fin_Find = GUICtrlCreateButton("Find Files", 10, 244, 280, 15) ;=-=-=-=-=-=-=-=-=-= ;Create Results Tab ;=-=-=-=-=-=-=-=-=-= $resTab = GUICtrlCreateTabItem("Results") $res_Results = GUICtrlCreateListView("Property Address|Price|Buyer|Seller|Close Date", 10, 35, 280, 200) GUICtrlSetState($res_Results, $GUI_DISABLE) ;=-=-=-=-=-=-=-=-=-= ;End Tab Control ;=-=-=-=-=-=-=-=-=-= GUICtrlCreateTabItem("") ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** GUI Set Events ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;GUI Events Handled by _GUIEventHandler() GUICtrlSetOnEvent($m_Options, "_GUIEventHandler") GUICtrlSetOnEvent($m_Exit, "_GUIEventHandler") GUICtrlSetOnEvent($m_Help, "_GUIEventHandler") GUICtrlSetOnEvent($ren_FolRE, "_GUIEventHandler") GUICtrlSetOnEvent($ren_FolPM, "_GUIEventHandler") GUICtrlSetOnEvent($ren_FolMC, "_GUIEventHandler") GUICtrlSetOnEvent($ren_Refresh, "_GUIEventHandler") GUICtrlSetOnEvent($ren_Remove, "_GUIEventHandler") GUICtrlSetOnEvent($ren_Rename, "_GUIEventHandler") GUICtrlSetOnEvent($sav_Browse, "_GUIEventHandler") GUICtrlSetOnEvent($sav_Save, "_GUIEventHandler") GUICtrlSetOnEvent($fin_Find, "_GUIEventHandler") ;System Events Handled by _SysEventHandler() GUISetOnEvent($GUI_EVENT_CLOSE, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_MINIMIZE, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_RESTORE, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_PRIMARYUP, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_SECONDARYUP, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_RESIZED, "_SysEventHandler", $m_HWnd) GUISetOnEvent($GUI_EVENT_DROPPED, "_SysEventHandler", $m_HWnd) GUISetState(@SW_SHOW, $m_HWnd) ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Main Program Loop ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 Sleep(100) WEnd ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** GUI Event Functions ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Func _GUIEventHandler() Local $the_Folder Switch @GUI_CtrlId Case $m_Exit _TerminateApp() Case $m_Options Case $m_Help Case $ren_FolRE _RefreshYears("RE") Case $ren_FolPM _RefreshYears("PM") Case $ren_FolMC _RefreshYears("MC") Case $ren_Refresh _RefreshFiles() Case $ren_Remove _RemoveFile(GUICtrlRead(GUICtrlRead($ren_File))) Case $ren_Rename If GUICtrlRead($ren_FolRE) = $GUI_CHECKED Then $the_Folder = "Real Estate" ElseIf GUICtrlRead($ren_FolPM) = $GUI_CHECKED Then $the_Folder = "Property Management" Elseif GUICtrlRead($ren_FolMC) = $GUI_CHECKED Then $the_Folder = "Miscellaneous" EndIf _RenameFile(GUICtrlRead(GUICtrlRead($ren_File)), $the_Folder, GUICtrlRead(GUICtrlRead($ren_Year)), GUICtrlRead($ren_RenFile)) Case $sav_Browse _FileOpenD() Case $sav_Save _SaveFileIndex() Case $fin_Find _FindFile() EndSwitch EndFunc Func _SysEventHandler() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE _TerminateApp() Case $GUI_EVENT_MINIMIZE Case $GUI_EVENT_RESTORE Case $GUI_EVENT_MAXIMIZE Case $GUI_EVENT_PRIMARYDOWN Case $GUI_EVENT_PRIMARYUP Case $GUI_EVENT_SECONDARYDOWN Case $GUI_EVENT_SECONDARYUP Case $GUI_EVENT_MOUSEMOVE Case $GUI_EVENT_RESIZED Case $GUI_EVENT_DROPPED EndSwitch EndFunc ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;---*** Define Functions ***--- ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Func _RefreshFiles() Local $search, $i = 0, $bool = 0 FileChangeDir($g_Dir) $search = FileFindFirstFile("*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Return EndIf While 1 $found = FileFindNextFile($search) If @error Then ExitLoop If Not(StringInStr(FileGetAttrib($found), "D")) Then If $bFile Then GUICtrlSetData(Eval("File" & $i), $found) Else Assign("File" & $i, GUICtrlCreateListViewItem($found & "|", $ren_File), 2) $bool = 1 EndIf EndIf $i += 1 WEnd FileClose($search) If $bool Then $bFile = 1 EndIf $i = 0 EndFunc Func _RefreshYears($option = "") Local $fol = 0, $folName = "", $search, $i = 0, $bool = 0 If $option = "RE" Then $fol = GUICtrlRead($ren_FolRE) $folName = "Real Estate" ElseIf $option = "PM" Then $fol = GUICtrlRead($ren_FolPM) $folName = "Property Management" ElseIf $option = "MC" Then $fol = GUICtrlRead($ren_FolMC) $folName = "Miscellaneous" Else $fol = 0 $folName = "" EndIf FileChangeDir($g_Dir & "\" & $folName & "\") $search = FileFindFirstFile("*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Return EndIf While 1 $found = FileFindNextFile($search) If @error Then ExitLoop If StringInStr(FileGetAttrib($found), "D") Then If $bYear Then GUICtrlSetData(Eval("Year" & $i), $found) Else Assign("Year" & $i, GUICtrlCreateListViewItem($found & "|", $ren_Year), 2) $bool = 1 EndIf EndIf $i += 1 WEnd FileClose($search) If $bool Then $bYear = 1 EndIf $i = 0 EndFunc Func _RemoveFile($del_file, $mov_file = "") Local $confirm = "", $i = 0 FileChangeDir($g_Dir) If $mov_file = "" Then $confirm = MsgBox(4, "WARNING!", "You are about to delete: " & @CRLF & $del_file & @CRLF & "Are you sure you want to continue?") Else $confirm = 6 EndIf If $confirm = 6 Then GUICtrlDelete(GUICtrlRead($ren_File)) For $i = 0 To 10 Step 1 FileDelete($del_file) Sleep(250) If FileExists($del_file) Then ContinueLoop Else Return EndIf Next MsgBox(0, "ERROR", "File: " & $del_file & "has not been deleted. Please remove the file manually.") EndIf EndFunc Func _RenameFile($old_file, $folder, $year, $new_file) Local $i = 0, $ret, $path, $buyer, $seller, $temp If StringRight($new_file, 4) <> ".pdf" Then $new_file = $new_file & ".pdf" EndIf If Not(StringInStr($new_file, "-")) Then MsgBox(0, "ERROR", "Please use the naming convention as described in the example." & @CRLF & "Seller-Buyer.pdf" & @CRLF & "Please go back and use a proper naming convention.") Return EndIf $path = $g_Dir & $folder & "\" & $year & "\" $temp = StringSplit(StringTrimRight($new_file, 4), "-") $seller = $temp[1] $buyer = $temp[2] For $i = 0 To 10 Step 1 FileCopy($g_Dir & $old_file, $path & $new_file) Sleep(250) If FileExists($path & $new_file) Then $ret = MsgBox(4, "Save Info Now?", "Would you like to save the indexing information now?") If $ret = 6 Then GUICtrlSetData($sav_Seller, $seller) GUICtrlSetData($sav_Buyer, $buyer) GUICtrlSetData($sav_Path, $path) GUICtrlSetData($sav_File, $new_file) Sleep(250) ControlFocus($wTitle, "", 6) ControlSend($wTitle, "", 6, "{RIGHT}") GUICtrlSetData($ren_RenFile, "Seller-Buyer.pdf") EndIf _RemoveFile($old_file, 1) Return Else ContinueLoop EndIf Next MsgBox(0, "ERROR", "File: " & $old_file & "has not been deleted. Please remove the file manually.") ;MsgBox(0, "Test", "Old File: " & $old_file & @CRLF & "Folder: " & $folder & @CRLF & "Year: " & $year & @CRLF & "New File: " & $new_file) EndFunc Func _FileOpenD() Local $path, $temp, $file, $count $path = GUICtrlRead($sav_Path) If $path = "" Then $path = $g_Dir $temp = FileOpenDialog("Select a File", $path, "All Files (*.*)") $path = StringLeft($temp, StringInStr($temp, "\", 0, -1)) $file = StringRight($temp, StringLen($temp) - StringLen($path)) $temp = StringSplit(StringTrimRight($file, 4), "-") $seller = $temp[1] $buyer = $temp[2] GUICtrlSetData($sav_Seller, $seller) GUICtrlSetData($sav_Buyer, $buyer) GUICtrlSetData($sav_Path, $path) GUICtrlSetData($sav_File, $file) EndFunc Func _SaveFileIndex() Local $seller, $buyer, $listAgent, $sellAgent, $propAddy, $closeDate, $price, $path, $file $seller = GUICtrlRead($sav_Seller) $buyer = GUICtrlRead($sav_Buyer) $listAgent = GUICtrlRead($sav_ListAgent) $sellAgent = GUICtrlRead($sav_SellAgent) $propAddy = GUICtrlRead($sav_PropAddy) $closeDate = GUICtrlRead($sav_CloseDate) $price = GUICtrlRead($sav_Price) $path = GUICtrlRead($sav_Path) $file = GUICtrlRead($sav_File) If $seller = "" Then MsgBox(0, "ERROR", "Missing Seller information.", 3) Return ElseIf $buyer = "" Then MsgBox(0, "ERROR", "Missing Buyer information.", 3) Return ElseIf $listAgent = "" Then MsgBox(0, "ERROR", "Missing Listing Agent information.", 3) Return ElseIf $sellAgent = "" Then MsgBox(0, "ERROR", "Missing Selling Agent information.", 3) Return ElseIf $propAddy = "" Then MsgBox(0, "ERROR", "Missing Property Address information.", 3) Return ElseIf $closeDate = "" Then MsgBox(0, "ERROR", "Missing Closing Date information.", 3) Return ElseIf $price = "" Then MsgBox(0, "ERROR", "Missing Price information.", 3) Return ElseIf $path = "" Then MsgBox(0, "ERROR", "Missing Path information.", 3) Return ElseIf $file = "" Then MsgBox(0, "ERROR", "Missing Filename information.", 3) Return EndIf _SQLite_QueryNoResult(-1, "INSERT INTO fIndex(fPrice, fSeller, fBuyer, fCloseD, fPAddress, fLAgent, fSAgent, fPath, fFile) VALUES('" & $price & "', '" & $seller & "', '" & $buyer & "', '" & $closeDate & "', '" & $propAddy & "', '" & $listAgent & "', '" & $sellAgent & "', '" & $path & "', '" & $file & "')") MsgBox(0, "Sucess", "File has been sucessfully indexed!", 3) GUICtrlSetData($sav_Seller, "") GUICtrlSetData($sav_Buyer, "") GUICtrlSetData($sav_ListAgent, "") GUICtrlSetData($sav_SellAgent, "") GUICtrlSetData($sav_PropAddy, "") GUICtrlSetData($sav_CloseDate, "") GUICtrlSetData($sav_Price, "") GUICtrlSetData($sav_Path, "") GUICtrlSetData($sav_File, "") EndFunc Func _FindFile() Local $sql, $rows, $hQuery, $i, $bool Local $PAddress, $Price, $Buyer, $Seller, $CloseDate ;Set Values equal to database columns for easy access through array (instead of $rows[number] you have $rows[$Price]) $PAddress = 5 $Price = 1 $Buyer = 3 $Seller = 2 $CloseDate = 4 $i = 0 $bool = 0 $sql = _SQL_Create() If @error Then MsgBox(0, "ERROR", "SQL Error: No input strings") Return EndIf MsgBox(0, "Test", _SQLite_Query(-1, $sql, $hQuery)) MsgBox(0, "Test", "$hQuery: " & $hQuery) InputBox("Test", "SQL Output", $sql) While _SQLite_FetchData($hQuery, $rows) = $SQLITE_OK If $bSearch Then _GUICtrlListViewDeleteAllItems($res_Results) $bool = 0 EndIf Assign("Result" & $i, GUICtrlCreateListViewItem($rows[$PAddress] & "|" & $rows[$Price] & "|" & $rows[$Buyer] & "|" & $rows[$Seller] & "|" & $rows[$CloseDate], $res_Results)) $i += 1 WEnd $bool = 1 GUICtrlSetState($res_Results, $GUI_ENABLE) If $bool Then $bSearch = 1 EndIf $i = 0 EndFunc Func _SQL_Create() Local $seller, $buyer, $listAgent, $sellAgent, $propAddy, $cFromDate, $cToDate, $pFrom, $pTo, $SQL_String $SQL_String = "SELECT * FROM fIndex WHERE " ;Start SQL String for finding the needed file $seller = GUICtrlRead($fin_Seller) $buyer = GUICtrlRead($fin_Buyer) $listAgent = GUICtrlRead($fin_ListAgent) $sellAgent = GUICtrlRead($fin_SellAgent) $propAddy = GUICtrlRead($fin_PropAddy) $cFromDate = GUICtrlRead($fin_CFromDate) $cToDate = GUICtrlRead($fin_CToDate) $pFrom = GUICtrlRead($fin_PFrom) $pTo = GUICtrlRead($fin_PTo) ;Setup SQL_String to only include items that are filled in on the Find Tab. If $seller <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fSeller LIKE '" & $seller & "' " EndIf If $buyer <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fBuyer LIKE '" & $buyer & "' " EndIf If $listAgent <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fLAgent LIKE '" & $listAgent & "' " EndIf If $sellAgent <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fSAgent LIKE '" & $sellAgent & "' " EndIf If $propAddy <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fPAddress LIKE '" & $propAddy & "' " EndIf If $cFromDate <> "" AND $cToDate <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fCloseD BETWEEN '" & $cFromDate & "' AND '" & $cToDate & "' " ElseIf $cFromDate <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fCloseD LIKE '" & $cFromDate & "' " EndIf If $pFrom <> "" AND $pTo <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fPrice BETWEEN '" & $pFrom & "' AND '" & $pTo & "' " ElseIf $pFrom <> "" Then If StringRight($SQL_String, 6) <> "WHERE " Then $SQL_String = $SQL_String & "AND " $SQL_String = $SQL_String & "fPrice LIKE '" & $pFrom & "' " EndIf ;Check to make sure SQL_String has been built by above If...EndIf statements. If StringRight($SQL_String, 6) = "WHERE " Then SetError(1) ;@error set to 1 due to no SQL_String value. Return 1 EndIf $SQL_String = $SQL_String & ";" Return $SQL_String EndFunc Func _TerminateApp() GUIDelete($m_HWnd) _SQLite_Close() _SQLite_Shutdown() Exit EndFunc I appreciate everyone's time. I have tried quite a few solutions, and nothing seems to be really working 100% JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
GaryFrost Posted June 2, 2006 Share Posted June 2, 2006 there is 3 ways to delete items from the listview _GUICtrlListViewDeleteAllItems _GUICtrlListViewDeleteItem _GUICtrlListViewDeleteItemsSelected I think the help file covers pretty well how to use each. Unfortunattly I can't run the above script at work, not with-out dicing it up 1st, due to the sqlite3.dll. Gary SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
JSThePatriot Posted June 2, 2006 Author Share Posted June 2, 2006 If you take a look at my script in the function I mentioned you will notice that I have used one of your three functions, and have used as described in the helpfile. My problem after using your function is I cannot repopulate my list with more than one item. I cant at the moment chop the code without re-writing it. I will see what I can do. I would love if we can get this resolved ASAP as this is just one of 3 projects I really need to complete today. Thanks for taking a peek, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
GaryFrost Posted June 2, 2006 Share Posted June 2, 2006 not sure why your using an assign in that function, the following should work fine. GUICtrlCreateListViewItem($rows[$PAddress] & "|" & $rows[$Price] & "|" & $rows[$Buyer] & "|" & $rows[$Seller] & "|" & $rows[$CloseDate], $res_Results) oÝ÷ Ù©ÞÅ©©êué^¶)àjYZÖv)à²Âä²·©y«^vºÚ"µÍÚ[ÛYH ÑÝZPÛÛÝ[Ë]LÉÝÂÚ[ÛYH ÑÝZSÝY]Ë]LÉÝÂÜ ÌÎNÓ]ÝXÛUÉÌÎNËJB[H ÌÍÛÝY]Ë ÌÍÐÑ[]P[ ÌÍÐÑ^] ÌÍÛÙË ÌÍÜ] ÌÍÔÝ]ÂÕRPÜX]J ][ÝÓÝY]È[]H[][É][ÝËÎLÌBÌÍÛÝY]ÈHÕRPÝÜX]SÝY]Ê ][ÝØÛÛ_ÛÛÛÛÉ][ÝË ÌÌLMJBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L_]L_[ÜLI][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L]L[ÜL][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[Lß]Lß[ÜLÉ][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M]M[ÜM ][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M_]M_[ÜMI][ÝË ÌÍÛÝY]ÊBÌÍÐÑ[]P[HÕRPÝÜX]P]Û ][ÝÑ[]H[][É][ÝËMLL BÌÍÐÑ^]HÕRPÝÜX]P]Û ][ÝÑ^] ][ÝËÌ ÌÌ BÌÍÔÝ]ÈHÕRPÝÜX]SX[ ][ÝÉ][ÝËÌÎL]Ô ÌÍÔÔ×ÔÕSÑS ÌÍÔÔ×ÐÑSTJBÕRTÙ]Ý]J BÚ[HBIÌÍÛÙÈHÕRQÙ]ÙÊ BTÙ[XÝBPØÙH ÌÍÛÙÈH ÌÍÑÕRWÑUSÐÓÔÑHÜ ÌÍÛÙÈH ÌÍÐÑ^]BBQ^]ÛÜBPØÙH ÌÍÛÙÈH ÌÍÐÑ[]P[BBRY ÑÕRPÝÝY]Ñ[]P[][È ÌÍÛÝY]ÊJH[BBBQÕRPÝÙ]]J ÌÍÔÝ]Ë ÌÎNÑ[]Y[][ÉÌÎNÊBBBBTÛY L BBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L_]L_[ÜLI][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L]L[ÜL][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[Lß]Lß[ÜLÉ][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M]M[ÜM ][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M_]M_[ÜMI][ÝË ÌÍÛÝY]ÊBBBQ[ÙBBBBQÕRPÝÙ]]J ÌÍÔÝ]Ë ÌÎNÑ[]HZ[Y ÌÎNÊBBBQ[YQ[Ù[XÝÑ[^] SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
JSThePatriot Posted June 2, 2006 Author Share Posted June 2, 2006 not sure why your using an assign in that function, the following should work fine. GUICtrlCreateListViewItem($rows[$PAddress] & "|" & $rows[$Price] & "|" & $rows[$Buyer] & "|" & $rows[$Seller] & "|" & $rows[$CloseDate], $res_Results) oÝ÷ Ù©ÞÅ©©êué^¶)àjYZÖv)à²Âä²·©y«^vºÚ"µÍÚ[ÛYH ÑÝZPÛÛÝ[Ë]LÉÝÂÚ[ÛYH ÑÝZSÝY]Ë]LÉÝÂÜ ÌÎNÓ]ÝXÛUÉÌÎNËJB[H ÌÍÛÝY]Ë ÌÍÐÑ[]P[ ÌÍÐÑ^] ÌÍÛÙË ÌÍÜ] ÌÍÔÝ]ÂÕRPÜX]J ][ÝÓÝY]È[]H[][É][ÝËÎLÌBÌÍÛÝY]ÈHÕRPÝÜX]SÝY]Ê ][ÝØÛÛ_ÛÛÛÛÉ][ÝË ÌÌLMJBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L_]L_[ÜLI][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L]L[ÜL][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[Lß]Lß[ÜLÉ][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M]M[ÜM ][ÝË ÌÍÛÝY]ÊBÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M_]M_[ÜMI][ÝË ÌÍÛÝY]ÊBÌÍÐÑ[]P[HÕRPÝÜX]P]Û ][ÝÑ[]H[][É][ÝËMLL BÌÍÐÑ^]HÕRPÝÜX]P]Û ][ÝÑ^] ][ÝËÌ ÌÌ BÌÍÔÝ]ÈHÕRPÝÜX]SX[ ][ÝÉ][ÝËÌÎL]Ô ÌÍÔÔ×ÔÕSÑS ÌÍÔÔ×ÐÑSTJBÕRTÙ]Ý]J BÚ[HBIÌÍÛÙÈHÕRQÙ]ÙÊ BTÙ[XÝBPØÙH ÌÍÛÙÈH ÌÍÑÕRWÑUSÐÓÔÑHÜ ÌÍÛÙÈH ÌÍÐÑ^]BBQ^]ÛÜBPØÙH ÌÍÛÙÈH ÌÍÐÑ[]P[BBRY ÑÕRPÝÝY]Ñ[]P[][È ÌÍÛÝY]ÊJH[BBBQÕRPÝÙ]]J ÌÍÔÝ]Ë ÌÎNÑ[]Y[][ÉÌÎNÊBBBBTÛY L BBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L_]L_[ÜLI][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[L]L[ÜL][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[Lß]Lß[ÜLÉ][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M]M[ÜM ][ÝË ÌÍÛÝY]ÊBBBBQÕRPÝÜX]SÝY]Ò][J ][ÝÛ[M_]M_[ÜMI][ÝË ÌÍÛÝY]ÊBBBQ[ÙBBBBQÕRPÝÙ]]J ÌÍÔÝ]Ë ÌÎNÑ[]HZ[Y ÌÎNÊBBBQ[YQ[Ù[XÝÑ[^] The reason I had the Assign() in there is because I was then using Eval() to go back through and update the ListViewItems(). I will try a few more things to see how it works. You can cut out all the sqlite.au3 functions (only like 2). JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
JSThePatriot Posted June 2, 2006 Author Share Posted June 2, 2006 Got it... I had to reset my $bSearch to 0 after deleting all items Thanks to everyone who looked. I will be updating all of my above code to use that GUIListView.au3 functions. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now