student_qt
student_qt

Reputation: 65

How Can I set id menu?

I have:

CMenu menu;
CRect rc;
GetWindowRect(&rc);
VERIFY(menu.CreatePopupMenu());
menu.AppendMenu(MF_STRING, 0, _T("Cancella"));

menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, point.x + rc.left, point.y + rc.top, this);

but I do't know how I can set ID menu.

Upvotes: 0

Views: 165

Answers (1)

Nick
Nick

Reputation: 471

Do something like

#define ID_MYACTION 42
menu.AppendMenu(MF_STRING, ID_MYACTION, _T("Cancella"));

Then insert a message handler for this item like

// in your message map:
ON_COMMAND(ID_MYACTION, OnMyAction)

// the handler itself:
void CMyWnd::OnMyAction()
{
    // do what you like
}

Upvotes: 1

Related Questions