HockeyFan Posted May 1, 2014 Share Posted May 1, 2014 Hello community! I would like some assistance with populating a ListView control with array information that contains Outlook PST file information using the _OL_PSTGet UDF. Here is what I have scrambled up so far... Any help would be much appreciated!! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <OutlookEX.au3> #include <GuiListView.au3> $GUI = GUICreate("Active PST List", 855, 661, -1, -1, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $ListView1 = GUICtrlCreateListView("No|Folder Name|Folder Objects|Path to PST", 16, 456, 826, 102) $Button1 = GUICtrlCreateButton("Exit", 343, 616, 145, 33) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUISetState(@SW_HIDE) Local $ItemNo = 0 Local $FolderName Local $FolderObjects Local $PathtoPST Global $oOutlook = _OL_Open() If @error <> 0 Then Exit Global $aPST = _OL_PSTGet($oOutlook) If @error <> 0 Then Exit local $array_aPST[UBound($aPST)-1][4] For $iI = 1 To $array_aPST[0] $array_aPST[$iI][0] = $ItemNo $array_aPST[$iI][1] = $FolderName $array_aPST[$iI][2] = $FolderObjects $array_aPST[$iI][3] = $PathtoPST Next _GUICtrlListView_AddArray($ListView1, $array_aPST) _OL_Close($oOutlook) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
BrewManNH Posted May 1, 2014 Share Posted May 1, 2014 One problem that I see is that you are creating an array ($array_aPST) and then right after that using it in the For loop counter without setting a value in it. Second is the array created is a 2D array, and your For loop is accessing it as a 1D array. I'm thinking you're using the wrong array in the for loop. Next, the variables you're putting into the array in the loop don't hold any values in them, they're all blank escept for $ItemNo which is always going to be zero. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
HockeyFan Posted May 1, 2014 Author Share Posted May 1, 2014 YIKES!! I guess I don't have a good handle on this at all. Back to the drawing board. Thanks for the input. Link to comment Share on other sites More sharing options...
HockeyFan Posted May 2, 2014 Author Share Posted May 2, 2014 OK...I've re-tooled my script...using another UDF by "Water", but I'm still the "tool" as I can not get the ListView data to display properly. How do I get the selected array data to populate across the columns instead of all in column 1? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <OutlookEX.au3> #include <GuiListView.au3> $GUI = GUICreate("Outlook Data File List", 855, 661, -1, -1, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $ListView1 = GUICtrlCreateListView("", 16, 156, 826, 400) $Button1 = GUICtrlCreateButton("Exit", 343, 616, 145, 33) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUISetState(@SW_HIDE) Global $FileSize Global $oOutlook = _OL_Open() If @error <> 0 Then Exit Global $aResult = _OL_StoreGet($oOutlook) If @error <> 0 Then Exit ; Add columns _GUICtrlListView_AddColumn($ListView1, "Column 1", 300) _GUICtrlListView_AddColumn($ListView1, "Column 2", 300) _GUICtrlListView_AddColumn($ListView1, "Column 3", 300) For $aX = 1 to $aResult[0][0] $FileSize = FileGetSize($aResult[$aX][2]) _GUICtrlListView_AddItem($ListView1, "[" & $ax & "]", 0) _GUICtrlListView_AddItem($ListView1, $aResult[$aX][2], 1) _GUICtrlListView_AddItem($ListView1, $FileSize, 2) Next _OL_Close($oOutlook) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
BrewManNH Posted May 2, 2014 Share Posted May 2, 2014 Here's a cut down version of the example from the help file to show how to add an array to a ListView. #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $iI, $iTimer, $idListview ; Create GUI GUICreate("ListView Add Array", 400, 300) $idListview = GUICtrlCreateListView("Items|Subitems 1|SubItems 2|SubItems 3", 2, 2, 394, 268) GUISetState(@SW_SHOW) ; Four column load Local $aItems[5000][4] ; Create a 2D array with 4 columns For $iI = 0 To UBound($aItems) - 1 $aItems[$iI][0] = "Item " & $iI $aItems[$iI][1] = "Item " & $iI & "-1" $aItems[$iI][2] = "Item " & $iI & "-2" $aItems[$iI][3] = "Item " & $iI & "-3" Next ; Add that array to the Listview _GUICtrlListView_AddArray($idListview, $aItems) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Your last post is only adding items to the listview as column 1 because if you want to use other columns of the LV you have to use _GUICtrlListView_AddSubItem for any column other than the first column. _GUICtrlListView_AddItem only adds items to the listview in column 0 (1) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
HockeyFan Posted May 2, 2014 Author Share Posted May 2, 2014 BrewManNH, Thank you for clearing that up! This is much better! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <OutlookEX.au3> #include <GuiListView.au3> $GUI = GUICreate("Outlook Data File List", 855, 661, -1, -1, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $ListView1 = GUICtrlCreateListView("", 16, 156, 826, 400) $Button1 = GUICtrlCreateButton("Exit", 343, 616, 145, 33) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUISetState(@SW_HIDE) Global $FileSize Global $oOutlook = _OL_Open() If @error <> 0 Then Exit Global $aResult = _OL_StoreGet($oOutlook) If @error <> 0 Then Exit ; Add columns _GUICtrlListView_AddColumn($ListView1, "Item#", 50) _GUICtrlListView_AddColumn($ListView1, "Path", 675) _GUICtrlListView_AddColumn($ListView1, "Size", 125) For $aX = 1 to $aResult[0][0] $FileSize = FileGetSize($aResult[$aX][2]) _GUICtrlListView_AddItem($ListView1, "[" & $ax & "]", 0) _GUICtrlListView_AddSubItem($ListView1,$aX-1, $aResult[$aX][2], 1, 1) _GUICtrlListView_AddSubItem($ListView1, $aX-1, $FileSize, 2, 2) Next _OL_Close($oOutlook) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit EndSwitch WEnd Now to figure out how to delete a row when an array item is an empty set in Column 2. Link to comment Share on other sites More sharing options...
HockeyFan Posted May 2, 2014 Author Share Posted May 2, 2014 Just for a learning experience, I re-wrote my script to mimic the example BrewManNH provided but it displays an extra row of repeated data. How do get rid of this extra row? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <OutlookEX.au3> #include <GuiListView.au3> Example() Func Example() Local $iI $GUI = GUICreate("Outlook Data File List", 855, 661, -1, -1, -1, BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE)) $ListView1 = GUICtrlCreateListView("", 16, 156, 826, 400) $Button1 = GUICtrlCreateButton("Exit", 343, 616, 145, 33) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUISetState(@SW_HIDE) Global $FileSize Global $oOutlook = _OL_Open() If @error <> 0 Then Exit Global $aResult = _OL_StoreGet($oOutlook) If @error <> 0 Then Exit ;Add columns _GUICtrlListView_AddColumn($ListView1, "Item#", 50) _GUICtrlListView_AddColumn($ListView1, "Path", 675) _GUICtrlListView_AddColumn($ListView1, "Size", 125) ; Create a 2D array with 3 columns For $iI = 1 To $aResult[0][0] $FileSize = FileGetSize($aResult[$iI][2]) $aResult[$iI-1][0] = "[" & $iI & "]" $aResult[$iI-1][1] = $aResult[$iI][2] $aResult[$iI-1][2] = $FileSize Next ; Add that array to the Listview _GUICtrlListView_AddArray($ListView1, $aResult) _OL_Close($oOutlook) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Exit EndSwitch WEnd EndFunc ;==>Example 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