控鍵名稱為"IDC_LIST1"
EX01---範例
取得與設定List 焦點Focus
int iItem = 0;
LPNMITEMACTIVATE temp = (LPNMITEMACTIVATE) pNMHDR;
iItem = temp->iItem;
((CListCtrl*)GetDlgItem(IDC_LIST1))->SetItemState(iItem,LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
((CListCtrl*)GetDlgItem(IDC_LIST1))->SetFocus();
EX02---範例
取得與設定Scrollbar 位置
int iItemScrollIndex = 0;
CRect crt;
((CListCtrl*)GetDlgItem(IDC_LIST1))->GetItemRect(0,crt,LVIR_BOUNDS);
m_iItemScrollIndex = ((CListCtrl*)GetDlgItem(IDC_LIST1))->GetTopIndex() * crt.Height();
((CListCtrl*)GetDlgItem(IDC_LIST1))->Scroll(CSize(0,iItemScrollIndex ));
沒有留言:
張貼留言