登录 注册
当前位置:主页 > 资源下载 > 31 > 使用MFC实现春节对联桌面小程序

使用MFC实现春节对联桌面小程序

  • 更新:2024-12-06 22:08:14
  • 大小:7KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:C++ - 后端
  • 格式:CPP

资源介绍

CPaintDC dc(this); CWnd * pWnd = dc.GetWindow(); CWnd * item1; item1=this->GetDlgItem(IDC_STATIC1); CRect * rect=new CRect; item1->GetWindowRect(rect); POINT a,b; a=rect->TopLeft(); b=rect->BottomRight(); ::ScreenToClient(this->m_hWnd,&a); ::ScreenToClient(this->m_hWnd,&b); CDC memDC; CBitmap cBitmap; BITMAP bitmap; cBitmap.LoadBitmap(IDB_BITMAP2); //通过资源标识加载图片 // HBITMAP hbmp=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),"F:\\MFC\\duilian2\\res\\下联.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); //通过文件路径加载图片 // cBitmap.Attach(hbmp); cBitmap.GetBitmap(&bitmap); maxh=bitmap.bmHeight; memDC.CreateCompatibleDC(&dc); memDC.SelectObject(&cBitmap); dc.BitBlt(a.x,a.y,bitmap.bmWidth,bitmap.bmHeight,&memDC,0,0,SRCCOPY); //////////////////////////////////////////////////////////////////////////// CRgn rgn,temprgn; rgn.CreateRectRgn(a.x,a.y,a.x+bitmap.bmWidth+5,a.y+h+4); item1=this->GetDlgItem(IDC_STATIC2); item1->GetWindowRect(rect); a=rect->TopLeft(); b=rect->BottomRight(); ::ScreenToClient(this->m_hWnd,&a); ::ScreenToClient(this->m_hWnd,&b); cBitmap.DeleteObject(); cBitmap.LoadBitmap(IDB_BITMAP1); cBitmap.GetBitmap(&bitmap); // memDC.CreateCompatibleDC(&dc); memDC.SelectObject(&cBitmap); dc.BitBlt(a.x-1,a.y-2,bitmap.bmWidth,bitmap.bmHeight,&memDC,0,0,SRCCOPY); temprgn.CreateRectRgn(a.x,a.y,a.x+bitmap.bmWidth+4,a.y+h+4); rgn.CombineRgn(&rgn,&temprgn,RGN_OR); /////////////////////////////////////////////////////////////////////////////////////// item1=this->GetDlgItem(IDC_STATIC3); item1->GetWindowRect(rect); a=rect->TopLeft(); b=rect->BottomRight(); ::ScreenToClient(this->m_hWnd,&a); ::ScreenToClient(this->m_hWnd,&b); cBitmap.DeleteObject(); cBitmap.LoadBitmap(IDB_BITMAP3); cBitmap.GetBitmap(&bitmap); maxw=bitmap.bmWidth; // memDC.CreateCompatibleDC(&dc); memDC.SelectObject(&cBitmap); dc.BitBlt(b.x-2-bitmap.bmWidth,a.y-2,bitmap.bmWidth,bitmap.bmHeight,&memDC,0,0,SRCCOPY); temprgn.DeleteObject(); temprgn.CreateRectRgn(b.x-w,a.y,b.x,a.y+bitmap.bmHeight); rgn.CombineRgn(&rgn,&temprgn,RGN_OR); /////////////////////////////////////////////////////////////////////////////// pWnd->SetWindowRgn(rgn,true); // pWnd->SetForegroundWindow(); rgn.DeleteObject(); temprgn.DeleteObject(); SetTimer(0,15,NULL); //CDialog::OnPaint();