PDA

View Full Version : خاکستری کردن آیتمی از یک Context Menu



zoncpp
شنبه 15 مهر 1385, 12: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);
}

zoncpp
دوشنبه 17 مهر 1385, 10:20 صبح
مرسی از همه دوستان
لینک زیر مشکل من رو حل کرد:
http://www.codeproject.com/cpp/cppforumfaq.asp#mfc_disablemenu