
注:学习版(express版)的VC++2010没有附带图形化的资源编辑器(不过可以允许你手工改代码),但是可以编译已经写好的资源文件
【文章标题】: VS2010 实现对话框程序设置背景图片void CMySendToDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this)// 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0)
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON)
int cyIcon = GetSystemMetrics(SM_CYICON)
CRect rect
GetClientRect(&rect)
int x = (rect.Width() - cxIcon + 1) / 2
int y = (rect.Height() - cyIcon + 1) / 2
// 绘制图标
dc.DrawIcon(x, y, m_hIcon)
}
else
{
CPaintDC dc(this)
CRect rect
GetClientRect(&rect)//获取客户的的大小
CDC memDC
CBitmap cBitmap
CBitmap* pOldMemBmp=NULL
cBitmap.LoadBitmap(IDB_BITMAP1)
memDC.CreateCompatibleDC(&dc)//创建一个设备对象上下文
pOldMemBmp=memDC.SelectObject(&cBitmap)
BITMAP bmp
cBitmap.GetBitmap(&bmp)
SetStretchBltMode(dc,STRETCH_HALFTONE)//据说能减少失真
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY)
memDC.SelectObject(pOldMemBmp)
CDialogEx::OnPaint()
}
}
try this code:BOOL CMainFrame::OnShowPopupMenu(CMFCPopupMenu* pMenuPopup)
{
if(pMenuPopup)
{
int iIndex = -1
CMFCPopupMenuBar* pMenuBar = pMenuPopup->GetMenuBar()
if (!CMFCToolBar::IsCustomizeMode()&&(NULL != pMenuBar) &&(iIndex=pMenuBar->CommandToIndex(ID_EDIT_PASTE))>=0)
{
pMenuPopup->InsertSeparator(iIndex+1)
pMenuPopup->InsertItem(CMFCToolBarMenuButton(IDS_EDIT_MYITEM_1,NULL,-1,_T("&MyItem 1")),iIndex+2)
pMenuPopup->InsertItem(CMFCToolBarMenuButton(IDS_EDIT_MYITEM_1 + 1,NULL,-1,_T("&MyItem 2")),iIndex+3)
}
}
return TRUE
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)