#include
"afxwin.h"
classFrame:publicCFrameWnd
{
public:
Frame()
{
Create(NULL,"PopUp Menu");
}
voidOnContextMenu(CWnd *p,CPointpt)
{
GetClientRect(&rect);
ClientToScreen(&rect);
if(rect.PtInRect(pt))
{
CMenu s;
s.CreatePopupMenu();
s.AppendMenu(MF_STRING,501,"&Create");
s.AppendMenu(MF_STRING,502,"&Design");
s.TrackPopupMenu(TPM_RIGHTALIGN|TPM_RIGHTBUTTON,pt.x,pt.y,this,0);
}
else
CFrameWnd::OnContextMenu(p,pt);
}
void create()
{
MessageBox("Craete Button
Clicked","New Creation");
}
void design()
{
MessageBox("Design Button
Creation","New Design");
}
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(Frame,CFrameWnd)
ON_WM_CONTEXTMENU()
ON_COMMAND(501,create)
ON_COMMAND(502,design)
END_MESSAGE_MAP()
classMain:publicCWinApp
{
public:intInitInstance()
{
Frame *p=new Frame();
p->ShowWindow(1);
m_pMainWnd=p;
return 1;
}
};
Main m;
No comments:
Write comments