pl123 Posted November 7, 2010 Posted November 7, 2010 I'm trying to make the total amount of RAM, pagefile, and virtual show in a ListView, so I used MemGetStats (), and setting the values for the arrays [1],[3],[5]: $MemStats = MemGetStats () $MemStats[1] = $TotalPhysRAM $MemStats[3] = $TotalPagefile $MemStats[5] = $TotalVirtual Then, I'm adding them to the ListView: Global Const $LeftBorder = 10 ; Left 'margin' size $MainWindow = GUICreate ($GUITitle, 400, 450) GUISetState (@SW_SHOW, $MainWindow) WinSetOnTop ($GUITitle, "", 1) GUICtrlCreateTab (5, 5, 390, 25) ---- omitted ---- $Tab[1] = GUICtrlCreateTabItem ("Computer Specs") GUICtrlCreateLabel ("******************", $LeftBorder, 35) GUICtrlCreateLabel ("******************", $LeftBorder, 50) GUICtrlCreateLabel ("————————————————————————————————————————————————————————————————", $LeftBorder, 62) ; divider line $MemStats = MemGetStats () $MemStats[1] = $TotalPhysRAM $MemStats[3] = $TotalPagefile $MemStats[5] = $TotalVirtual $SpecsList = GUICtrlCreateListView ("****************|Value", $LeftBorder, 75, 380, 300) GUICtrlCreateListViewItem ("Total Physical RAM|" & $TotalPhysRAM & "", $SpecsList) GUICtrlCreateListViewItem ("Total Pagefile|" & $TotalPagefile & "", $SpecsList) GUICtrlCreateListViewItem ("Total Virtual Memory|" & $TotalVirtual & "", $SpecsList) However, the three items do not show up on the list view thingy. Is there anything wrong? Thanks! =)
Moderators Melba23 Posted November 7, 2010 Moderators Posted November 7, 2010 pl123, Is there anything wrong?I am afraid so! MemGetStats returns an array already filled with the data. By using this code: $MemStats = MemGetStats () $MemStats[1] = $TotalPhysRAM $MemStats[3] = $TotalPagefile $MemStats[5] = $TotalVirtual you are replacing the data you have obtained with the contents of those 3 variables - which as you have not declared them is an empty string. Hence nothing to display in the ListView. What you need to do is reverse the order of the assignation statements like this: $MemStats = MemGetStats () $TotalPhysRAM = $MemStats[1] $TotalPagefile = $MemStats[3] $TotalVirtual = $MemStats[5] and you will find that your ListView magically fills with the data. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Fire Posted November 7, 2010 Posted November 7, 2010 Hallo) pl123 Personally i like Listview Here is my code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Global $avaray $Form1 = GUICreate("Test Programm", 510, 255, 389, 325) $ListView1 = GUICtrlCreateListView("Memory Load (%)" & "|" &"Total physical RAM" & "|" &"Available physical RAM" & "|", 80, 40, 361, 137) $Button1 = GUICtrlCreateButton("Re Scan", 96, 208, 89, 25, $WS_GROUP) $Button3 = GUICtrlCreateButton("Delete All Items", 344, 208, 89, 25, $WS_GROUP) $hcontextmenu=GUICtrlCreateContextMenu($ListView1) $contextmenu_item1=GUICtrlCreateMenuItem("Get Memory Load in (%)",$hcontextmenu) GUICtrlCreateMenuItem("",$hcontextmenu) $contextmenu_item2=GUICtrlCreateMenuItem("Get Total physical RAM",$hcontextmenu) GUICtrlCreateMenuItem("",$hcontextmenu) $contextmenu_item3=GUICtrlCreateMenuItem("Get Available physical RAM",$hcontextmenu) GUICtrlCreateMenuItem("",$hcontextmenu) $contextmenu_item4_get_all=GUICtrlCreateMenuItem("Get All in One :P",$hcontextmenu) GUISetState(@SW_SHOW) _getmem() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1;Rescan Mem and Populate it To Listview $avaray="" _GUICtrlListView_DeleteAllItems($ListView1) _getmem() Case $Button3 _GUICtrlListView_DeleteAllItems($ListView1) $emptymsg="Listview Emptied!" $asnwer=MsgBox(65,$emptymsg,$emptymsg & "Would you like Rescan Mem and Polulate Listview?",15) If $asnwer="1" Then _getmem() EndIf Case $contextmenu_item1 $i="0" MsgBox(64,"",_GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),$i)) Case $contextmenu_item2 $i="1" MsgBox(64,"",_GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),$i)) Case $contextmenu_item3 $i="2" MsgBox(64,"",_GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),$i)) Case $contextmenu_item4_get_all MsgBox(64,"","Memory Load (%) " &_GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),0) & @CRLF & _ "Total physical RAM " & _GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),1) & @CRLF & _ "Available physical RAM " & _GUICtrlListView_GetItemText(GUICtrlGetHandle($ListView1),_GUICtrlListView_GetSelectedIndices($ListView1),2)) ; EndSwitch WEnd Func _getmem() $avaray=MemGetStats() _populate() EndFunc ;==> _getmem() Func _populate() GUICtrlCreateListViewItem($avaray[0] & "|" & $avaray[1] & "|" & $avaray[2],$ListView1) EndFunc ; ==>_populate() [size="5"] [/size]
pl123 Posted November 7, 2010 Author Posted November 7, 2010 Ok, I got it fixed now. Thanks both of you for your help! =)
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