PopMenu
所属分类:界面编程
开发工具:Visual C++
文件大小:21KB
下载次数:15
上传日期:2014-06-03 13:20:40
上 传 者:
wpudn22
说明: VC++ PopMenu弹出式菜单例子源码,弹出式菜单(PopMenu)在程序界面上单击鼠标右键弹出的菜单就是弹出式菜单。通常情况下,或在窗体菜单栏内点击菜单时弹出,属于较基本的常用菜单了,希望VC++新手们可以参考哦
(VC++ PopMenu example source pop-up menu, the pop-up menu (PopMenu) in the program interface, right-click pop-up menu is a pop-up menu. Under normal circumstances, or click on the pop-up menu in the menu bar form, belong to the more commonly used basic menu, I hope VC++ novices can refer oh)
文件列表:
PopMenu\CHILDFRM.CPP (1529, 2013-12-12)
PopMenu\CHILDFRM.H (1403, 1999-01-23)
PopMenu\MAINFRM.CPP (2591, 2013-12-12)
PopMenu\MAINFRM.H (1550, 1999-01-23)
PopMenu\RES\BITMAP1.BMP (2026, 1999-01-23)
PopMenu\RES\TOOLBAR.BMP (1078, 1999-01-23)
PopMenu\RES\WZD.ICO (1078, 1999-01-23)
PopMenu\RES\WZD.RC2 (395, 1999-01-23)
PopMenu\RES\WZDDOC.ICO (1078, 1999-01-23)
PopMenu\RESOURCE.H (1100, 1999-01-23)
PopMenu\STDAFX.CPP (201, 1999-01-23)
PopMenu\STDAFX.H (987, 1999-01-23)
PopMenu\WZD.CPP (4265, 1999-01-23)
PopMenu\WZD.H (1333, 1999-01-23)
PopMenu\WZD.RC (14587, 1999-01-23)
PopMenu\WZD5.DSP (4708, 1999-01-23)
PopMenu\WZD5.DSW (530, 1999-01-23)
PopMenu\WZD6.DSP (4821, 1999-01-23)
PopMenu\WZD6.DSW (530, 1999-01-23)
PopMenu\WZDDLG.CPP (1652, 1999-01-23)
PopMenu\WZDDLG.H (1193, 1999-01-23)
PopMenu\WZDDOC.CPP (1718, 2013-12-12)
PopMenu\WZDDOC.H (1450, 1999-01-23)
PopMenu\WZDVIEW.CPP (3442, 1999-01-23)
PopMenu\WZDVIEW.H (1974, 1999-01-23)
PopMenu\RES (0, 2013-08-26)
PopMenu\WIZARD (0, 2013-08-26)
PopMenu (0, 2013-12-12)
/////////////////////////////////////////////////////////////////////
// Create Popup Menu Dialog Class...
/////////////////////////////////////////////////////////////////////
// 1) Create a popup menu resource with the menu items you require.
// 2) Create a dialog box resource with a picture control on one side and
// a static control on the other. Configure the picture control to hold a
// bitmap to appear along the side of the static control.
// 3) Size the static control and dialog template to conform to the size
// of the popup menu. You will need to perform the next steps to be able
// to see the final result.
// 4) Use the ClassWizard to create a dialog class that uses this template.
// 5) Add a WM_INITDIALOG message handler to position the dialog where the
// mouse was clicked:
BOOL CWzdDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// position where mouse button was clicked
CPoint pt;
GetCursorPos(&pt);
SetWindowPos(NULL,pt.x,pt.y,0,0,SWP_NOSIZE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
// 6) Add a WM_PAINT handler to display the popup menu:
void CWzdDialog::OnPaint()
{
CDialog::OnPaint();
// load up menu
CMenu menu;
menu.LoadMenu(IDR_WZD_MENU);
CMenu* pPopup = menu.GetSubMenu(0);
// get location of static control and display popup menu there
CRect rect;
GetDlgItem(IDC_MENU_STATIC)->GetWindowRect(&rect);
int nLeft=rect.right+2;
GetWindowRect(&rect);
pPopup->TrackPopupMenu(TPM_RIGHTBUTTON, nLeft, rect.top, GetParent());
// cancel this dialog
PostMessage(WM_CLOSE);
}
/////////////////////////////////////////////////////////////////////
// Modify View Class...
/////////////////////////////////////////////////////////////////////
// 1) Add message handler for right mouse button down to create dialog box.
void CWzdView::OnRButtonDown(UINT nFlags, CPoint point)
{
CWzdDialog dlg;
dlg.DoModal();
CView::OnRButtonDown(nFlags, point);
}
/////////////////////////////////////////////////////////////////////
// From: Visual C++ MFC Programming by Example by John E. Swanke
// Copyright (C) 1999 jeswanke. All rights reserved.
/////////////////////////////////////////////////////////////////////
近期下载者:
相关文件:
收藏者: