如何在List表的某些项中添加组合框控件,即实现下拉链表功能?可以添加新的项。紧急!!!!!!!!1111111
上回我发帖子有一位高手回复,但是我试了好像不行,没有反应。我对他里面的东东不是很明白。
如果那位高手看到的话希望你能给我解释下。谢谢。m_nRow,m_nCol,rect,是在哪里定义的是属于谁的。m_comboPurview是不是只需要定义就行了。是不是需要在initDialog里面初始化。void CUserManageDlg::OnDblclkListUser(NMHDR* pNMHDR, LRESULT* pResult)
{
CRect rcSubItem;
BOOL bInSubItem = FALSE;
CPoint pt = GetMessagePos();
m_listUserInfo.ScreenToClient(&pt);
CHeaderCtrl* pHeaderCtrl = m_listUserInfo.GetHeaderCtrl();
int nColumnCount = pHeaderCtrl- >GetItemCount();
int nItemCount = m_listUserInfo.GetItemCount();
for (int nCol = 1; nCol < nColumnCount; nCol ++)
{
if (bInSubItem)
break ;
for (int nItem = 0; nItem < nItemCount; nItem ++)
{
m_listUserInfo.GetSubItemRect(nItem, nCol, LVIR_BOUNDS, rcSubItem);
if (rcSubItem.PtInRect(pt))
{
bInSubItem = TRUE;
m_nCol = nCol;
m_nRow = nItem;
if (m_nCol == nColumnCount - 1)
『
rect.OffsetRect(-1, -1);
m_comboPurview.MoveWindow(&rect);
m_comboPurview.ShowWindow(SW_SHOW);
m_comboPurview.BringWindowToTop();
m_comboPurview.SetFocus();
m_comboPurview.SetCurSel(0);
』
break ;
}
}
}
*pResult = 0;
}
注意当listctrl失去焦点时,隐藏combox
上回我发帖子有一位高手回复,但是我试了好像不行,没有反应。我对他里面的东东不是很明白。
如果那位高手看到的话希望你能给我解释下。谢谢。m_nRow,m_nCol,rect,是在哪里定义的是属于谁的。m_comboPurview是不是只需要定义就行了。是不是需要在initDialog里面初始化。void CUserManageDlg::OnDblclkListUser(NMHDR* pNMHDR, LRESULT* pResult)
{
CRect rcSubItem;
BOOL bInSubItem = FALSE;
CPoint pt = GetMessagePos();
m_listUserInfo.ScreenToClient(&pt);
CHeaderCtrl* pHeaderCtrl = m_listUserInfo.GetHeaderCtrl();
int nColumnCount = pHeaderCtrl- >GetItemCount();
int nItemCount = m_listUserInfo.GetItemCount();
for (int nCol = 1; nCol < nColumnCount; nCol ++)
{
if (bInSubItem)
break ;
for (int nItem = 0; nItem < nItemCount; nItem ++)
{
m_listUserInfo.GetSubItemRect(nItem, nCol, LVIR_BOUNDS, rcSubItem);
if (rcSubItem.PtInRect(pt))
{
bInSubItem = TRUE;
m_nCol = nCol;
m_nRow = nItem;
if (m_nCol == nColumnCount - 1)
『
rect.OffsetRect(-1, -1);
m_comboPurview.MoveWindow(&rect);
m_comboPurview.ShowWindow(SW_SHOW);
m_comboPurview.BringWindowToTop();
m_comboPurview.SetFocus();
m_comboPurview.SetCurSel(0);
』
break ;
}
}
}
*pResult = 0;
}
注意当listctrl失去焦点时,隐藏combox
很多源码
你的动态创建
如m_comboPurview.create(...);