Click to See Complete Forum and Search --> : Menu + Activex, i need help


hajer
September 23rd, 2004, 10:42 AM
Hi All,

I'm implementing an activex control subclassing a listview,
i want to write a code that allows me to have a menu when i clicked on the header of the listview.
i wrote the following :


BOOL CActivexCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam;
LPNMHDR pNH = (LPNMHDR) lParam;

// wParam is zero for Header ctrl
if( wParam == 0 && pNH->code == NM_RCLICK )
{
// Right button was clicked on header
CPoint ptScreen(GetMessagePos());
CMenu menu;
VERIFY(menu.LoadMenu(IDR_POPUP1));
CMenu *popup = menu.GetSubMenu(0);
ASSERT(popup);
VERIFY(popup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
ptScreen.x, ptScreen.y, this, NULL));

}
return COleControl::OnNotify(wParam, lParam, pResult);
}


the problem encountred that when i execute my code, the menu appears but all items are disabled.

what is the problem ?
I need your help.