pacoxxl Posted May 21, 2006 Share Posted May 21, 2006 I have ListView with ListViewItem. How I can set focus at any ListViewItem ? this is my example, but dont works... expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> Dim $arr_ListViewItem[1] ;Create main/parent window $main = GuiCreate("TEST", 700, 260, -1, -1) GUISetBkColor (0xE0FFFF, $main) ; will change background color ; LIST VIEW $listview = GuiCtrlCreateListView("col1|col2|col3|col4|col5|col6", _ 3, 5, 694, 250, _ $LVS_NOSORTHEADER + $LVS_SINGLESEL + $LVS_SHOWSELALWAYS + $LVS_REPORT, _ BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_REGIONAL, $LVS_EX_TRACKSELECT)) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) _GUICtrlListViewJustifyColumn($listview,0,2) _GUICtrlListViewJustifyColumn($listview,4,2) _GUICtrlListViewJustifyColumn($listview,5,2) _GUICtrlListViewSetColumnWidth($listview,0,52) _GUICtrlListViewSetColumnWidth($listview,1,220) _GUICtrlListViewSetColumnWidth($listview,2,150) _GUICtrlListViewSetColumnWidth($listview,3,78) _GUICtrlListViewSetColumnWidth($listview,4,120) _GUICtrlListViewSetColumnWidth($listview,5,52) _GUICtrlListViewSetHoverTime ($listview, -1) For $i=0 To 1500 $arr_ListViewItem[$i] = GUICtrlCreateListViewItem ( "xxx|row_" & $i & "|adress|telefon|yyy|sum", $listview ) ReDim $arr_ListViewItem[$i+2] Next GUISetState(@SW_SHOW) GUICtrlSetState ( $arr_ListViewItem[300], $GUI_FOCUS ) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd [font="Courier New"][center]PACOxxl[/center][/font] Link to comment Share on other sites More sharing options...
GaryFrost Posted May 21, 2006 Share Posted May 21, 2006 _GUICtrlListViewSetItemSelState 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...
pacoxxl Posted May 21, 2006 Author Share Posted May 21, 2006 (edited) _GUICtrlListViewSetItemSelStateO.K.but if I press UP,DOWN key then i am still at first ListViewItem Edited May 21, 2006 by pacoxxl [font="Courier New"][center]PACOxxl[/center][/font] Link to comment Share on other sites More sharing options...
pacoxxl Posted May 22, 2006 Author Share Posted May 22, 2006 (edited) Bug Fix : file : GuiListView.au3 expandcollapse popup;=============================================================================== ; ; Description: _GUICtrlListViewSetItemSelState ; Parameter(s): $h_listview - controlID ; $i_index - Zero based index of the item ; $i_selected - Optional: set the state of the item (1 = selected, 0 = not selected) (default = 1) ; $i_focused - Optional: set the state of the item (1 = focused, 0 = not focused) (default = 0) ; Requirement: None ; Return Value(s): 1 if successful, 0 otherwise ; If error then $LV_ERR is returned ; User CallTip: _GUICtrlListViewSetItemSelState($h_listview, $i_index[[, $i_selected = 1], $i_focused = 0]) Sets the Item Selected/UnSelected + optionally Focused/UnFocused (required: <GuiListView.au3>) ; Author(s): Gary Frost (custompcs at charter dot net) ; Note(s): $i_index = -1 sets all items for MultiSelect ListView ; ;=============================================================================== Func _GUICtrlListViewSetItemSelState($h_listview, $i_index, $i_selected = 1, $i_focused = 0) Local $struct = "int;int;int;int;int;ptr;int;int;int;int;int;ptr", $ret Local $p = DllStructCreate($struct) Local $s_selected Local $s_focused If @error Then Return $LV_ERR EndIf If ($i_selected == 1) Then $i_selected = $LVNI_SELECTED $s_selected = $LVIS_SELECTED Else $i_selected = 0 $s_selected = 0 EndIf If ($i_focused == 1) Then $i_focused = $LVNI_FOCUSED $s_focused = $LVIS_FOCUSED Else $i_focused = 0 $s_focused = 0 EndIf DllStructSetData($p, 1, $LVIF_STATE) DllStructSetData($p, 2, $i_index) DllStructSetData($p, 4, $i_selected + $i_focused) DllStructSetData($p, 5, $s_selected + $s_focused) If IsHWnd($h_listview) Then Local $a_ret = DllCall("user32.dll", "int", "SendMessage", "hwnd", $h_listview, "int", $LVM_SETITEMSTATE, "int", $i_index, "ptr", DllStructGetPtr($p)) $ret = $a_ret[0] Else $ret = GUICtrlSendMsg($h_listview, $LVM_SETITEMSTATE, $i_index, DllStructGetPtr($p)) EndIf ; DllStructDelete($p) Return $ret EndFunc ;==>_GUICtrlListViewSetItemSelState thank you ric Edited May 22, 2006 by pacoxxl [font="Courier New"][center]PACOxxl[/center][/font] 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