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

时间:2014-02-08 05:42:42
【文件属性】:

文件名称:春节对联MFC实现桌面小程序

文件大小:7KB

文件格式:CPP

更新时间:2014-02-08 05:42:42

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

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();


网友评论

  • 没能打开成功
  • 代码不完整
  • 不错的小程序,可以自己设计着玩,蛮好的