bob.frew Posted June 21, 2008 Posted June 21, 2008 Hi people, hope someone can help. I had this kind of thing working ok before. Then updating code for 3.2.12.0 I find it no longer does. All I want to do is click on a line on the ListView and change the background colour to red. I believe I am achieving this, but can't see it because of the "focus" line. I don't mind if I lose the "focus" line altogether or change its colour or temporarily disable it just so long as I can see red after selecting the line. Have tried to suss this for a while now and drawn a blank. All pushes in the right direction welcome. Thanks Bob expandcollapse popup; View catalogue Opt("ExpandEnvStrings", 0) Opt("ExpandVarStrings", 1) Opt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ListviewConstants.au3> #include <Array.au3> #include <Date.au3> #Include <File.au3> #Include <GuiListView.au3> Dim $CVwindow, $cv_catname, $cv_label1, $cv_label2 Dim $cv_add_cat_button, $cv_find_desc_button, $cv_show_catalogue_button, $cv_tvguide_button Dim $cv_overview_button, $cv_finish_button, $cv_toggle_button Dim $cv_desc, $cv_end, $cv_selection_ID Dim $cv_listview Dim $cv_lastred = -1; Dim $cv_lv_selected = 0; Dim $cv_catA[1000] Dim $cv_catN[1000] Dim $version = "V1.20" Dim $version_date = "Apr 2008" Dim $ico = "_images\cat.ico" Dim $today = @MDAY & "/" & @MON & "/" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC Dim $window_colour = 0x00005b; dark blue Dim $f_colour_front = 0x000000; white Dim $f_colour_back = 0x007c7c; pale green Dim $font = "Arial Narrow" Dim $font2 = "Century Gothic" Dim $catname = " Catalogue " & $version Dim $MArrN[1000][5] Dim $MArrA[1000][5] Dim $MArr_highest_index Dim $tArray[5], $g = 0 viewCat() Exit ; ------------------------------------------------------------------------------------------------ Func viewCat() $cv_catname = $catname & " View" loadMArrA() ; _ArrayDisplay($MArrA,"source arr") makeCatalogueViewGUI() GUIDelete($CVwindow) Return EndFunc ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Func makeCatalogueViewGUI() $CVwindow = GUICreate($cv_catname, 800, 460, 30, 10, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetOnEvent($GUI_EVENT_CLOSE, "cv_quit_view") GUISetBkColor($window_colour) ; - - - - - $cv_listview = GUICtrlCreateListView(" Id|Title", 10, 30, 400, 430) GUICtrlSetColor($cv_listview,0xffffff) GUICtrlSetBkColor ($cv_listview,0x00347c) $cv_desc = GuiCtrlCreateEdit("No description available", 420,30,360,430,$WS_VSCROLL) GUICtrlSetFont ($cv_desc,12, 400,0 , $font) GUICtrlSetColor($cv_desc,0xffffff) GUICtrlSetBkColor ($cv_desc,0x00347c) ; set alphabetic sequence For $g = 0 To $MArr_highest_index $cv_catA[$g] = GUICtrlCreateListViewItem($MArrA[$g][0] & "|" & $MArrA[$g][1] , $cv_listview) If $cv_catA[$g] = 0 Then MsgBox(0, "Error", "Unable to add to ListView for ." & $MArrA[$g][0]) EndIf GUICtrlSetOnEvent($cv_catA[$g], "cv_catA_event") Next _GUICtrlListView_SetColumnWidth($cv_listview, 0, $LVSCW_AUTOSIZE); size columns _GUICtrlListView_SetColumnWidth($cv_listview, 1, $LVSCW_AUTOSIZE) GUISetState(@SW_SHOW, $CVwindow) Do ; GUICtrlSetState ( $cv_listview, $GUI_NOFOCUS ) Until $cv_end = 1 Return EndFunc ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Func cv_quit_view() $cv_end = 1 Return EndFunc ;==> ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Func cv_catA_event() If $cv_lastred <> -1 Then GUICtrlSetBkColor($cv_catA[$cv_lastred], 0x00347c) ; restore normal EndIf Local $ListIndices = _GUICtrlListView_GetSelectedIndices($cv_listview) If $ListIndices <> $LV_ERR Then ; something selected $cv_lastred = $ListIndices ; GUICtrlSetBkColor($cv_catA[$cv_lastred], 0xff2200) ; dark red orange ; _GUICtrlListView_SetItemSelected($cv_listview,$cv_lastred,0,0) ; unselect, unfocus GUICtrlSetBkColor($cv_catA[$cv_lastred], 0xff2200) ; dark orange _GUICtrlListView_SetItemFocused($cv_listview, $cv_lastred, 0) ; unfocus _GUICtrlListView_SetItemSelected($cv_listview, $cv_lastred, 0) ; unselect setFieldsForA() GUISetState($CVwindow) ;MsgBox(0, "In cv_catA_event()", "after setFieldsForA()") EndIf Return EndFunc ; -------------------------------------------------------------------------- Func setFieldsForA() Local $i = $MArrA[$cv_lastred][0] ; id Local $t = $MArrA[$cv_lastred][1] ; title Local $d = $MArrA[$cv_lastred][3] ; description Local $y = $MArrA[$cv_lastred][4] ; year If $d = "" Then $d = "No description available" EndIf GUICtrlSetData($cv_desc, $d) ; description Return EndFunc ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Func loadLine($ln) $tArray = StringSplit($ln, "^") $MArrA[$g][0] = $tArray[1]; id $MArrA[$g][1] = $tArray[2]; title $MArrA[$g][2] = $tArray[3]; subt $MArrA[$g][3] = $tArray[4]; desc $MArrA[$g][4] = $tArray[5]; date $g = $g + 1 Return EndFunc ; -------------------------------------------------------------------------- Func loadMArrA() loadLine("0043^A Private Function^^With its gentle, witty portrait of postwar Britain and its sly digs at bourgeois aspirations, this comedy has the stamp of Ealing about it. Scripted by Alan Bennett, it is an often hilarious mixture of well-observed social comedy and sometimes laborious earthy humour, much of the latter being inspired by the bodily functions of a pig being fattened for a feast to celebrate the 1947 royal wedding. Michael Palin does a nice line in mortified meekness, but he is upstaged by Maggie Smith, as his scheming wife, and Liz Smith, whose eccentric antics and distracted ramblings provide some of the highlights.^2004") loadLine("0044^Some Like It Hot^^^") loadLine("0045^Addams Family Values^^Sequel to the black comedy about the morbid Addams clan. The new nanny turns out to be a serial murderer bent on stealing Uncle Fester's money. When Pugsley and Wednesday's suspicions are aroused, the nanny persuades Morticia and Gomez to dispatch them to summer camp, and while she wreaks havoc at the family home, the siblings are forced to watch wholesome children's television and participate in group hugs.^") loadLine("0046^Monsters Inc.^^^") loadLine("0047^Chicken Run^^Award-winning animation from the Aardman team, telling the story of a band of chickens doomed to a life of egg-laying on a Yorkshire chicken farm. When a flamboyant American rooster arrives on the scene, the hens hope he can teach them to fly to freedom. However, when a chicken-pie making machine is installed, their need becomes urgent and they must devise other means of escape. With the voices of Mel Gibson and Julia Sawalha.^") loadLine("0048^Kind Hearts And Coronets^^^") loadLine("0049^The Ipcress File^^Spy thriller in which agent Harry Palmer is assigned to investigate a bizarre brain drain among scientists, and finds himself embroiled in a world of espionage where nobody can be trusted and nothing is what it seems. Based on the novel by Len Deighton, it spawned two sequels.^") $MArr_highest_index = $g - 1 Return EndFunc ; -------------------------------------------------------------------------- ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Func deleteCatalogueViewGUI() GUIDelete($CVwindow) Return EndFunc AutoIt is great - leave me alone and I'll play for hours
Linux Posted June 21, 2008 Posted June 21, 2008 Hi! GUICtrlSetBkColor($cv_catA[$cv_lastred], 0xff2200) ; dark orange _GUICtrlListView_SetItemSelected($cv_listview, 1) _GUICtrlListView_SetItemSelected($cv_listview, 1,False) You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"
bob.frew Posted June 22, 2008 Author Posted June 22, 2008 Many thanks for that Linux. It now works as I wanted it to. I wish I could say the same for my understanding of the process. Are these statements operating on the whole ListView control rather than an item within it? Anyone know of anything I should go away and read? Cheers Bob AutoIt is great - leave me alone and I'll play for hours
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