James Posted May 17, 2007 Share Posted May 17, 2007 (edited) Hey, I am making a database program for Dad's work. Basically, you enter Usernames, passwords and then you assign an image to a user. Once that has happened, all the data is written to a .ini file. My example is: [Users] Names=James [Image] Image=C:\Documents and Settings\Keith\My Documents\My Pictures\Home and Family\Jim\103_0330.JPG [Password] Password=password Then you can read the data, by importing all the .ini information into a ListView. This is where my problem gets annoying. I have made the image show up (I will fix that later so that when you click a username it will display the image, I just cant because it isn't displaying them) but the other data, the Username, Password and Image Location are not displayed. I have looked in the help file and examples, but cannot find any answer to it Here is the bit that sets the image and should also set the other data. Func _GetUser() $ImportImage = IniReadSection($UserFile, "Image") $ImportName = IniReadSection($UserFile, "Users") $ImportPassword = IniReadSection($UserFile, "Password") For $a = 1 To $ImportImage[0][0] GuiCtrlSetImage($UserImage, $ImportImage[$a][1]) ; Works _GUICtrlListViewSetItemText($UserList, 3, 1, FileGetLongName(IniReadSection($UserFile, "Image"), 1)) Next For $b = 1 To $ImportName[0][0] _GUICtrlListViewSetItemText($UserList, 2, 0, $ImportName[$b][1]) Next For $c = 1 to $ImportPassword[0][0] _GUICtrlListViewSetItemText($UserList, 2, 1, $ImportPassword[$c][1]) Next EndFunc Any help is much appreciated. Thanks, James Edited May 18, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
GaryFrost Posted May 17, 2007 Share Posted May 17, 2007 Set will only change a ListView item that has already been created, are you creating the item(s) 1st? 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...
James Posted May 17, 2007 Author Share Posted May 17, 2007 Right. I tried that, but maybe I didn't do it once I had created the funtion correctly. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted May 17, 2007 Author Share Posted May 17, 2007 Gary, I am still having problems with it. I created one item to test. But nothing changes. CODE expandcollapse popup#include <GUIConstants.au3> #include <GuiStatusBar.au3> #include <GuiListView.au3> #include <File.au3> Dim $UserFile, $UserList $UserFile = @ScriptDir & '\names.ini' Local $gGui, $StatusBar, $sMsg, $Users, $Btn_Exit, $msg, $Status Local $a_PartsRightEdge[3] = [120, 350, -1] Local $a_PartsText[3] = ["UserBase Started", "", "Welcome to UserBase"] $gGui = GUICreate("UserBase :: JBro Software", 725, 571, -1, -1, $WS_SIZEBOX) GUISetIcon("C:\WINDOWS\system32\shell32.dll", 104) $StatusBar = _GUICtrlStatusBarCreate ($gGui, $a_PartsRightEdge, $a_PartsText) _GUICtrlStatusBarSetIcon($StatusBar, 0, "shell32.dll", 104) _GUICtrlStatusBarSetIcon($StatusBar, 2, "shell32.dll", 24) $UserList = GUICtrlCreateListView("Username | Password | Image Location", 5, 0, 300, 450, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER)) GuiCtrlCreateListViewItem("Data1|Data2|Data3", $UserList ) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT) _GUICtrlListViewSetColumnWidth($UserList, 0, 100) $UserImage = GuiCtrlCreatePic("", 325, 100, 200, 210, BitOR($SS_NOTIFY,$WS_GROUP)) $File = GUICtrlCreateMenu("&File") $New = GUICtrlCreateMenuItem("&New", $File) $Open = GUICtrlCreateMenuItem("Open", $File) $Exit = GUICtrlCreateMenuItem("&Exit", $File) $Edit = GUICtrlCreateMenu("&Edit") $EditUser = GUICtrlCreateMenuItem("&Edit User", $Edit) $ImportUsers = GuiCtrlCreateMenuItem("Import User(s)", $Edit) $EditPassword = GUICtrlCreateMenuItem("Edit Password", $Edit) $EditImage = GuiCtrlCreateMenuItem("Replace User Image", $Edit) $View = GUICtrlCreateMenu("&View") $Font = GUICtrlCreateMenuItem("&Font", $View) $Help = GUICtrlCreateMenu("&Help") $About = GUICtrlCreateMenuItem("&About", $Help) $HelpMe = GUICtrlCreateMenuItem("Help &Me", $Help) GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE, $Exit Exit Case $iMsg = $GUI_EVENT_RESIZED _GUICtrlStatusBarResize($StatusBar) Case $New _New() Case $ImportUsers ;MsgBox(0x2000, "Error", "Error Importing Users." & @CRLF & "Reason for error: GetUser() not available") _GetUser() Case $EditPassword _EditPassword() EndSwitch WEnd Func _New() $NewUser = InputBox("Create New User", "What would you like to call the user?") $UserCheck = MsgBox(0x4, "Create New User", "Are you sure you wish to call your user, " & $NewUser & "?") If $UserCheck = 6 Then $UserImageFile = FileOpenDialog("Assign Image to user" & $NewUser, @MyDocumentsDir & "\My Pictures", "Image Files (*.gif;*.jpg;*.png)", 9) IniWrite($UserFile, "Users", "Names", $NewUser) IniWrite($UserFile, "Image", "Image", $UserImageFile) $NewPassword = InputBox("Create New User", "What password would you like to use for, " & $NewUser & "?") IniWrite($UserFile, "Password", "Password", $NewPassword) MsgBox(64, "Create New User", "New user, " & $NewUser & " has been succesfully create!") Else MsgBox(0x2000, "Create New User", "There was an error creating new user, " & $NewUser) EndIf EndFunc Func _GetUser() $ImportImage = IniReadSection($UserFile, "Image") $ImportName = IniReadSection($UserFile, "Users") $ImportPassword = IniReadSection($UserFile, "Password") For $a = 1 To $ImportImage[0][0] GuiCtrlSetImage($UserImage, $ImportImage[$a][1]) _GUICtrlListViewSetItemText($UserList, 1, 1, FileGetLongName(IniReadSection($UserFile, "Image"), 1)) Next For $b = 1 To $ImportName[0][0] _GUICtrlListViewSetItemText($UserList, 1, 0, $ImportName[$b][1]) Next For $c = 1 to $ImportPassword[0][0] _GUICtrlListViewSetItemText($UserList, 1, 1, $ImportPassword[$c][1]) Next EndFunc Func _EditPassword() $UserPassword = IniReadSection($UserFile, "Password") $PassNotify = MsgBox(0x4, "Change Password", "Warning, you are about to change the password are you sure you wish to continue?") If $PassNotify = 6 Then $NewPass = InputBox("Change Password", "What would you like to change the password to?") IniWriteSection($UserFile, "Password", $NewPass) If $NewPass = "" Then MsgBox(0x2000, "Change Password", "There was an error changing password. You cannot enter a blank password!") EndIf EndIf EndFunc Once I have the names fixed I can then start fixing the .ini problem of it over-writing the existing data. Then I can make the list names show an image when clicked. James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
GaryFrost Posted May 17, 2007 Share Posted May 17, 2007 (edited) Gary, I am still having problems with it. I created one item to test. But nothing changes.Once I have the names fixed I can then start fixing the .ini problem of it over-writing the existing data. Then I can make the list names show an image when clicked.JamesHow about an ini file to test with, this is where your having the problems correct?Currently your trying to change index 1, if you only have 1 item in the listview the index is 0 Edited May 17, 2007 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. Link to comment Share on other sites More sharing options...
GaryFrost Posted May 17, 2007 Share Posted May 17, 2007 (edited) Func _GetUser() If _GUICtrlListViewGetSelectedCount($UserList) Then $ImportImage = IniReadSection($UserFile, "Image") $ImportName = IniReadSection($UserFile, "Users") $ImportPassword = IniReadSection($UserFile, "Password") $User_index = Int(_GUICtrlListViewGetSelectedIndices($UserList)) For $a = 1 To $ImportImage[0][0] GUICtrlSetImage($UserImage, $ImportImage[$a][1]) _GUICtrlListViewSetItemText($UserList, $User_index, 2, FileGetLongName($ImportImage[$a][1], 1)) Next For $b = 1 To $ImportName[0][0] _GUICtrlListViewSetItemText($UserList, $User_index, 0, $ImportName[$b][1]) Next For $c = 1 To $ImportPassword[0][0] _GUICtrlListViewSetItemText($UserList, $User_index, 1, $ImportPassword[$c][1]) Next EndIf EndFunc ;==>_GetUser Edited May 17, 2007 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. Link to comment Share on other sites More sharing options...
GaryFrost Posted May 17, 2007 Share Posted May 17, 2007 I think this is more of what your shooting for: Func _GetUser() $User_index = _GUICtrlListViewGetItemCount($UserList) $ImportImage = IniReadSection($UserFile, "Image") $ImportName = IniReadSection($UserFile, "Users") $ImportPassword = IniReadSection($UserFile, "Password") For $a = 1 To $ImportImage[0][0] GUICtrlCreateListViewItem($ImportName[$a][1] & "|" & $ImportPassword[$a][1] & "|" & FileGetLongName($ImportImage[$a][1], 1), $UserList) GUICtrlSetImage($UserImage, $ImportImage[$a][1]) Next EndFunc ;==>_GetUser 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...
James Posted May 18, 2007 Author Share Posted May 18, 2007 Thanks Gary. I would of replied but I have been sleeping. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted May 18, 2007 Author Share Posted May 18, 2007 Sorry. I have a couple of problems. Its the first time I have worked with a ListView program so I'm struggling a bit. I try looking in the helpfile and changing examples so that it should work, but it doesn't Anyway, my two problems:Ini file keeps over writing other usersWhen you select a user the image is not shownMore detail, when I create a new user the current .ini information is over written, so there is always one user And for my second problem. When you select the user from the list view the image does not change. I tried the following:Dim $ret, $UserList $ret = _GUICtrlListViewGetItemText($UserList, _GUICtrlListViewGetSelectedIndices($UserList)) If ($ret <> $LV_ERR) Then GuiCtrlSetImage($UserImage, $Ret) $ret = _GUICtrlListViewGetItemText($UserList, _GUICtrlListViewGetSelectedIndices($UserList), 0) If ($ret <> $LV_ERR) Then GUICtrlSetImage($UserImage, $ret) EndIf Else _GUICtrlStatusBarSetText($StatusBar, "Nothing Selected", 2) EndIfBut that doesn't do anything, and all I did was change where the error message is shown and what happens when one list is selected. I'm pretty sure I need to add or remove something so that it can find the list view data for where the image is stored, but my brain is not doing it.Thankyou,James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted May 18, 2007 Author Share Posted May 18, 2007 (edited) For my second problem I tried doing:For $b = 1 To $ImportImage $ImageData = _GUICtrlListViewGetItemText($UserList, 0, 3) GUICtrlSetImage($UserImage, $ImageData) Next oÝ÷ زإÚ'¡«ÚR#ºËj{lyì!Ê+p¢{lzÛaz)çZµ¬!zv®±êèØ^+-Ëç-yÓ2ìmjÛ^ZºÚ"µÍÜ ÌÍØHHÈ ÌÍÒ[Ü[XYÙBIÌÍÓ[ÝÙTÜÈHÕRQÙ]ÝÛÜ[Ê BRY ÌÍÓ[ÝÙTÜÖÌHOH ÌÍÕÙÝ H[ÕRPÝÙ][XYÙJ ÌÍÕÙ[XYÙK[QÙ]ÛÓ[YJ ÌÍÒ[Ü[XYÙJK ÌÍÕÙÝ B^oÝ÷ ØÚ%¹ÉÉø§jVµé©µ«¢+Ø)½ÈÀÌØíôÄQ¼ÀÌØí%µÁ½ÉÑ%µlÁulÁt($ÀÌØí5½ÕÍA½ÌôU%Ñ ÕÉͽÉ%¹¼ ¤(%% ÀÌØí5½ÕÍA½ÍlÑtôôÀÌØíUÍÉ1¥ÍФQ¡¸($%U% ÑɱMÑ%µ ÀÌØíUÍÉ%µ°¥±Ñ1½¹9µ ÀÌØí%µÁ½ÉÑ%µlÀÌØíulÅt¤¤(%¹%)9áÐ(And it works! Now to fix the .ini problem! I thought it worked. But it automatically changes the image. So basically, its not worked. And I can't find out if it has untill the .ini problem is fixed and I cant do that neither Edited May 18, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted May 18, 2007 Author Share Posted May 18, 2007 How do I add more information to a .ini file? [Users] Names=James [Image] Image=C:\Documents and Settings\Keith\My Documents\My Pictures\Home and Family\Jim\103_0330.JPG [Password] Password=password Now lets say I create a new user, it automatically overwrites the current data. How can I just add to it? I know its something to do with: Func _New() $NewUser = InputBox("Create New User", "What would you like to call the user?") $UserCheck = MsgBox(0x4, "Create New User", "Are you sure you wish to call your user, " & $NewUser & "?") If $UserCheck = 6 Then $UserImageFile = FileOpenDialog("Assign Image to user" & $NewUser, @MyDocumentsDir & "\My Pictures", "Image Files (*.gif;*.jpg;*.png)", 9) IniWrite($UserFile, "Users", "Names", $NewUser) IniWrite($UserFile, "Image", "Image", $UserImageFile) $NewPassword = InputBox("Create New User", "What password would you like to use for, " & $NewUser & "?") IniWrite($UserFile, "Password", "Password", $NewPassword) MsgBox(64, "Create New User", "New user, " & $NewUser & " has been succesfully create!") Else MsgBox(0x2000, "Create New User", "There was an error creating new user, " & $NewUser) EndIf EndFunc ;==>_New But I cannot figure out how to add if there is already data in that file. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted May 18, 2007 Author Share Posted May 18, 2007 (edited) Right, I have fixed the problem of ini. It now writes like:[Users] james=james abc=abc [Image] C:\DOCUME~1\Keith\MYDOCU~1\MYPICT~1\Canals\DSC_0693.JPG=C:\Documents and Settings\Keith\My Documents\My Pictures\Canals\DSC_0693.JPG C:\DOCUME~1\Keith\MYDOCU~1\MYPICT~1\CONGLE~2\DSC_4224.JPG=C:\Documents and Settings\Keith\My Documents\My Pictures\Congleton Carnival july 06\DSC_4224.JPG [Password] a=a pass=passNow the following:Func _GetUser() $User_index = _GUICtrlListViewGetItemCount($UserList) $ImportImage = IniReadSection($UserFile, "Image") $ImportName = IniReadSection($UserFile, "Users") $ImportPassword = IniReadSection($UserFile, "Password") For $a = 1 To $ImportImage[0][0] GUICtrlCreateListViewItem($ImportName[$a][1] & "|" & $ImportPassword[$a][1] & "|" & FileGetLongName($ImportImage[$a][1], 1), $UserList) ;GUICtrlSetImage($UserImage, $ImportImage[$a][1]) Next For $b = 1 To $ImportImage[0][0] $MousePos = GUIGetCursorInfo() If ($MousePos[4] == $UserList) Then GUICtrlSetImage($UserImage, FileGetLongName($ImportImage[$b][1])) Next EndFunc ;==>_GetUserWill show the image once each, then it will stay on the last image. Why? I just cant seem to understand. Any help?JamesEdit: Cut down code. Edited May 18, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted May 18, 2007 Author Share Posted May 18, 2007 I have finally done it! Case $iMsg = $GUI_EVENT_PRIMARYDOWN $pos = GUIGetCursorInfo() $ImportImage = IniReadSection($UserFile, "Image") For $b = 1 To $ImportImage[0][0] If ($pos[4] == $UserList) Then GUICtrlSetImage($UserImage, $ImportImage[$b][1]) EndIf Next Woop! Just alot of hard work and time. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted May 18, 2007 Author Share Posted May 18, 2007 Damn. I am wrong again. It works but it is buggy. When I try and edit the names.ini file, the images switch through, even though there are no names in the list. CODE expandcollapse popup; User Management System ; Written by James Brooks ; Help Links: ; http://www.autoitscript.com/forum/index.php?showtopic=46148 : _GUICtrlListViewSetItemText() Problem #include <GUIConstants.au3> #include <GuiStatusBar.au3> #include <GuiListView.au3> #include <File.au3> Dim $UserFile, $UserList, $ret, $pos, $UserImage $font = "Comic Sans MS" $UserFile = @ScriptDir & '\names.ini' Local $gGui, $StatusBar, $sMsg, $Users, $Btn_Exit, $msg, $Status Local $a_PartsRightEdge[3] = [120, 350, -1] Local $a_PartsText[3] = ["UserBase Started", "", "Welcome to UserBase"] $gGui = GUICreate("UserBase :: JBro Software", 725, 571, -1, -1, $WS_SIZEBOX) GUISetIcon("C:\WINDOWS\system32\shell32.dll", 104) $StatusBar = _GUICtrlStatusBarCreate($gGui, $a_PartsRightEdge, $a_PartsText) _GUICtrlStatusBarSetIcon($StatusBar, 0, "shell32.dll", 104) _GUICtrlStatusBarSetIcon($StatusBar, 2, "shell32.dll", 24) $UserList = GUICtrlCreateListView("Username | Password | Image Location", 5, 0, 300, 450, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER)) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT) _GUICtrlListViewSetColumnWidth($UserList, 3, $LVSCW_AUTOSIZE) $UserImage = GUICtrlCreatePic("", 325, 100, 200, 210, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetTip(-1, "User Image for User: " & IniReadSection($UserFile, "Users")) $File = GUICtrlCreateMenu("&File") $New = GUICtrlCreateMenuItem("&New", $File) $Open = GUICtrlCreateMenuItem("Open", $File) GUICtrlCreateMenuitem("", $File, 2) $Exit = GUICtrlCreateMenuItem("&Exit", $File) $Edit = GUICtrlCreateMenu("&Edit") $EditUser = GUICtrlCreateMenuItem("&Edit User", $Edit, 3) $ImportUsers = GUICtrlCreateMenuItem("Import User(s)", $Edit) $EditPassword = GUICtrlCreateMenuItem("Edit Password", $Edit) $EditImage = GUICtrlCreateMenuItem("Replace User Image", $Edit) $View = GUICtrlCreateMenu("&View") $Sort = GUICtrlCreateMenuItem("&Sort List", $View) $Clear = GuiCtrlCreateMenuItem("Clear Items", $View) $Help = GUICtrlCreateMenu("&Help") $About = GUICtrlCreateMenuItem("&About", $Help) GUICtrlCreateMenuitem("", $Help, 2) $HelpMe = GUICtrlCreateMenuItem("Help &Me", $Help) GUISetState(@SW_SHOW) Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($UserList)] While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE, $Exit Exit Case $iMsg = $GUI_EVENT_RESIZED _GUICtrlStatusBarResize($StatusBar) Case $New _New() Case $ImportUsers ;MsgBox(0x2000, "Error", "Error Importing Users." & @CRLF & "Reason for error: GetUser() not available") _GetUser() Case $Clear _GUICtrlListViewDeleteAllItems($UserList) GuiCtrlSetImage($UserImage, "") Case $EditPassword $DataCheck = MsgBox(0x4, "Edit names.ini file", "Are you sure you wish to edit names.ini data?") If $DataCheck = 6 Then _EditData() Else ; EndIf Case $Sort _GUICtrlListViewSort($UserList, $B_DESCENDING, GUICtrlGetState($UserList)) Case $iMsg = $GUI_EVENT_PRIMARYDOWN $pos = GUIGetCursorInfo() $ImportImage = IniReadSection($UserFile, "Image") For $b = 1 To $ImportImage[0][0] If ($pos[4] == $UserList) Then GUICtrlSetImage($UserImage, $ImportImage[$b][1]) EndIf Next EndSwitch WEnd Func _New() $NewUser = InputBox("Create New User", "What would you like to call the user?") $UserCheck = MsgBox(0x4, "Create New User", "Are you sure you wish to call your user, " & $NewUser & "?") If $UserCheck = 6 Then $UserImageFile = FileOpenDialog("Assign Image to user" & $NewUser, @MyDocumentsDir & "\My Pictures", "Image Files (*.gif;*.jpg;*.png)", 9) IniWrite($UserFile, "Users", $NewUser, $NewUser) IniWrite($UserFile, "Image", FileGetShortName($UserImageFile), $UserImageFile) $NewPassword = InputBox("Create New User", "What password would you like to use for, " & $NewUser & "?") IniWrite($UserFile, "Password", $NewPassword, $NewPassword) MsgBox(64, "Create New User", "New user, " & $NewUser & " has been succesfully create!") Else MsgBox(0x2000, "Create New User", "There was an error creating new user, " & $NewUser) EndIf EndFunc ;==>_New Func _GetUser() $User_index = _GUICtrlListViewGetItemCount($UserList) $ImportImage = IniReadSection($UserFile, "Image") $ImportName = IniReadSection($UserFile, "Users") $ImportPassword = IniReadSection($UserFile, "Password") For $a = 1 To $ImportImage[0][0] GUICtrlCreateListViewItem($ImportName[$a][1] & "|" & $ImportPassword[$a][1] & "|" & FileGetLongName($ImportImage[$a][1], 1), $UserList) ;GUICtrlSetImage($UserImage, $ImportImage[$a][1]) Next EndFunc ;==>_GetUser Func _EditData() $dData = FileRead(FileOpen(@ScriptDir & '\names.ini', 0)) $dGui = GUICreate("Edit users.ini", 594, 202, 220, 284) $IniData = GUICtrlCreateEdit("", 0, 0, 593, 161, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL)) GUICtrlSetData(-1, $dData) $SaveData = GUICtrlCreateButton("&Save", 432, 168, 73, 25, 0) $ExitData = GUICtrlCreateButton("Exit", 512, 168, 73, 25, 0) GUISetState() While WinActive($dGui) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $ExitData GuiDelete($dGui) Case $SaveData FileClose($dData) EndSwitch WEnd EndFunc Any help is much appreciated, because I cannot understand it. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
GaryFrost Posted May 18, 2007 Share Posted May 18, 2007 Not sure what all your trying to do, but take a look at this expandcollapse popup; User Management System ; Written by James Brooks ; Help Links: ; http://www.autoitscript.com/forum/index.php?showtopic=46148 : _GUICtrlListViewSetItemText() Problem #include <GUIConstants.au3> #include <GuiStatusBar.au3> #include <GuiListView.au3> #include <File.au3> Global Const $DebugIt = 1 Global Const $WM_NOTIFY = 0x004E ;ListView Events Global Const $NM_FIRST = 0 Global Const $NM_LAST = (-99) Global Const $NM_OUTOFMEMORY = ($NM_FIRST - 1) Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) Dim $UserFile, $UserList, $ret, $pos, $UserImage $font = "Comic Sans MS" $UserFile = @ScriptDir & '\names.ini' Local $gGui, $StatusBar, $sMsg, $Users, $Btn_Exit, $msg, $Status Local $a_PartsRightEdge[3] = [120, 350, -1] Local $a_PartsText[3] = ["UserBase Started", "", "Welcome to UserBase"] $gGui = GUICreate("UserBase :: JBro Software", 725, 571, -1, -1, $WS_SIZEBOX) GUISetIcon("C:\WINDOWS\system32\shell32.dll", 104) $StatusBar = _GUICtrlStatusBarCreate($gGui, $a_PartsRightEdge, $a_PartsText) _GUICtrlStatusBarSetIcon($StatusBar, 0, "shell32.dll", 104) _GUICtrlStatusBarSetIcon($StatusBar, 2, "shell32.dll", 24) $UserList = GUICtrlCreateListView("Username | Password | Image Location", 5, 0, 300, 450, $LVS_SHOWSELALWAYS) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP) GUICtrlSendMsg($UserList, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT) _GUICtrlListViewSetColumnWidth($UserList, 3, $LVSCW_AUTOSIZE) $UserImage = GUICtrlCreatePic("", 325, 100, 200, 210, BitOR($SS_NOTIFY, $WS_GROUP)) GUICtrlSetTip(-1, "User Image for User: " & IniReadSection($UserFile, "Users")) $File = GUICtrlCreateMenu("&File") $New = GUICtrlCreateMenuItem("&New", $File) $Open = GUICtrlCreateMenuItem("Open", $File) GUICtrlCreateMenuItem("", $File, 2) $Exit = GUICtrlCreateMenuItem("&Exit", $File) $Edit = GUICtrlCreateMenu("&Edit") $EditUser = GUICtrlCreateMenuItem("&Edit User", $Edit, 3) $ImportUsers = GUICtrlCreateMenuItem("Import User(s)", $Edit) $EditPassword = GUICtrlCreateMenuItem("Edit Password", $Edit) $EditImage = GUICtrlCreateMenuItem("Replace User Image", $Edit) $View = GUICtrlCreateMenu("&View") $Sort = GUICtrlCreateMenuItem("&Sort List", $View) $Clear = GUICtrlCreateMenuItem("Clear Items", $View) $Help = GUICtrlCreateMenu("&Help") $About = GUICtrlCreateMenuItem("&About", $Help) GUICtrlCreateMenuItem("", $Help, 2) $HelpMe = GUICtrlCreateMenuItem("Help &Me", $Help) GUISetState(@SW_SHOW) _GUICtrlStatusBarResize($StatusBar) ;Register WM_NOTIFY events GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount($UserList) ] While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Exit Exit Case $GUI_EVENT_RESIZED _GUICtrlStatusBarResize($StatusBar) Case $New _New() Case $ImportUsers ;MsgBox(0x2000, "Error", "Error Importing Users." & @CRLF & "Reason for error: GetUser() not available") _GetUser() Case $Clear _GUICtrlListViewDeleteAllItems($UserList) GUICtrlSetImage($UserImage, "") Case $EditPassword $DataCheck = MsgBox(0x4, "Edit names.ini file", "Are you sure you wish to edit names.ini data?") If $DataCheck = 6 Then _EditData() Else ; EndIf Case $UserList _GUICtrlListViewSort($UserList, $B_DESCENDING, GUICtrlGetState($UserList)) ;~ Case $iMsg = $GUI_EVENT_PRIMARYDOWN ;~ $pos = GUIGetCursorInfo() ;~ $ImportImage = IniReadSection($UserFile, "Image") ;~ For $b = 1 To $ImportImage[0][0] ;~ If ($pos[4] == $UserList) Then ;~ GUICtrlSetImage($UserImage, $ImportImage[$b][1]) ;~ EndIf ;~ Next EndSwitch WEnd Func _New() $NewUser = InputBox("Create New User", "What would you like to call the user?") $UserCheck = MsgBox(0x4, "Create New User", "Are you sure you wish to call your user, " & $NewUser & "?") If $UserCheck = 6 Then $UserImageFile = FileOpenDialog("Assign Image to user" & $NewUser, @MyDocumentsDir & "\My Pictures", "Image Files (*.gif;*.jpg;*.png)", 9) IniWrite($UserFile, "Users", $NewUser, $NewUser) IniWrite($UserFile, "Image", FileGetShortName($UserImageFile), $UserImageFile) $NewPassword = InputBox("Create New User", "What password would you like to use for, " & $NewUser & "?") IniWrite($UserFile, "Password", $NewPassword, $NewPassword) MsgBox(64, "Create New User", "New user, " & $NewUser & " has been succesfully create!") Else MsgBox(0x2000, "Create New User", "There was an error creating new user, " & $NewUser) EndIf EndFunc ;==>_New Func _GetUser() $User_index = _GUICtrlListViewGetItemCount($UserList) $ImportImage = IniReadSection($UserFile, "Image") $ImportName = IniReadSection($UserFile, "Users") $ImportPassword = IniReadSection($UserFile, "Password") For $a = 1 To $ImportImage[0][0] GUICtrlCreateListViewItem($ImportName[$a][1] & "|" & $ImportPassword[$a][1] & "|" & FileGetLongName($ImportImage[$a][1], 1), $UserList) GUICtrlSetImage(-1, $ImportImage[$a][1]) Next EndFunc ;==>_GetUser Func _EditData() $dData = FileRead(@ScriptDir & '\names.ini') $dGui = GUICreate("Edit users.ini", 594, 202, 220, 284) $IniData = GUICtrlCreateEdit("", 0, 0, 593, 161, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetData(-1, $dData) $SaveData = GUICtrlCreateButton("&Save", 432, 168, 73, 25, 0) $ExitData = GUICtrlCreateButton("Exit", 512, 168, 73, 25, 0) GUISetState() While WinActive($dGui) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $ExitData GUIDelete($dGui) Case $SaveData $dData = FileOpen(@ScriptDir & '\names.ini', 2) FileWrite($dData, GUICtrlRead($IniData)) FileClose($dData) EndSwitch WEnd EndFunc ;==>_EditData Func ListView_Click() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("$NM_CLICK") ;---------------------------------------------------------------------------------------------- GUICtrlSetImage($UserImage, _GUICtrlListViewGetItemText($UserList, _GUICtrlListViewGetSelectedIndices($UserList), 2)) EndFunc ;==>ListView_Click Func ListView_DoubleClick() ;---------------------------------------------------------------------------------------------- If $DebugIt Then _DebugPrint("$NM_DBLCLK") ;---------------------------------------------------------------------------------------------- MsgBox(0, "Double Clicked", _GUICtrlListViewGetItemText($UserList, _GUICtrlListViewGetSelectedIndices($UserList))) EndFunc ;==>ListView_DoubleClick ; ; WM_NOTIFY event handler Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $UserList Select Case $event = $NM_CLICK ListView_Click() Case $event = $NM_DBLCLK ListView_DoubleClick() EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 EndFunc ;==>WM_Notify_Events Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite("!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint 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...
James Posted May 18, 2007 Author Share Posted May 18, 2007 Perfect. Works a treat. Thanks Gary Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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