zoncpp
شنبه 15 مهر 1385, 13:24 عصر
i want display an item of context menu, gray and disable. Therefore i call EnableMenuItem function in my code, but it don't work correctly.
what do i do???
void CMyView::OnContextMenu(CWnd* pWnd, CPoint point)
{
if (WindowFromPoint(point) == GetDlgItem(IDC_LISTCTRL))
{
CMenu MyMenu;
MyMenu.LoadMenu(IDR_LISTMENU);
CMenu *pContextMenu;
pContextMenu = MyMenu.GetSubMenu(0);
if(m_iListIndex == -1)
{
pContextMenu->EnableMenuItem(IDR_MENUITEM1, MF_GRAYED);
}
else
{
}
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
point.x, point.y, AfxGetMainWnd());
}
UpdateData(FALSE);
}
what do i do???
void CMyView::OnContextMenu(CWnd* pWnd, CPoint point)
{
if (WindowFromPoint(point) == GetDlgItem(IDC_LISTCTRL))
{
CMenu MyMenu;
MyMenu.LoadMenu(IDR_LISTMENU);
CMenu *pContextMenu;
pContextMenu = MyMenu.GetSubMenu(0);
if(m_iListIndex == -1)
{
pContextMenu->EnableMenuItem(IDR_MENUITEM1, MF_GRAYED);
}
else
{
}
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
point.x, point.y, AfxGetMainWnd());
}
UpdateData(FALSE);
}