I am doing a win32 application using List view control,I used extended style LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT.My application demands for force selection of row(ie,Searching for an item,if it found select that item via program)I tryed with both LVM_SETITEMSTATEas well as ListView_SetItemState,But iam not getting as selected
First code using macro
1 2 3 4
itemNo=Search(lvItem.pszText)//Search the item and returned the item index,working fine
MessageBox()//Item already exist
ListView_SetItemState(hWnd, itemNo, LVIS_SELECTED | LVIS_FOCUSED,
0x000f); //fails
using LVM_SETITEMSTATE
1 2 3 4 5 6 7
itemNo=Search(lvItem.pszText)//Search the item and returned the item index,working fine
MessageBox()//Item already exist
lvItem.iItem=itemNo;
lvItem.mask=LVIF_STATE;
lvItem.state=LVIS_SELECTED;
lvItem.stateMask=0x00f;
SendMessage(hWnd,LVM_SETITEMSTATE,itemNo,(LPARAM)&lvItem);
You have to set hte extended style using ListView_SetExtendedListViewStyle(hWnd, LVS_EX_FULLROWSELECT);
As Andy illustrated for me, the 1st parameter in the CreateWindowEx API affects only the window and not the control. So, in order to add any extended style to any control, you need to set it using the corresponding macro. For ListView for example: ListView_SetExtendedListViewStyle