基本信息
源码名称:生日快乐小程序源码(可任意修改)
源码大小:22.35M
文件格式:.rar
开发语言:C/C++
更新时间:2019-10-31
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

本资源是关于生日快乐的一个程序的源代码,是送给好友,女友的最佳的生日礼物。其中对图片的处理采用的是透视化处理,对一些对图片处理比较感兴趣的人来说是相当有用!!


背景图片在自动交替显示,文字可随意修改,带生日快乐 背景音乐,非常不错





// BirthdayDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Birthday.h"
#include "BirthdayDlg.h"
#include "mmsystem.h"
#include "FrontDraw.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define NCLIP1 6
#define NCLIP2 0
#define ST 1
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBirthdayDlg dialog

CBirthdayDlg::CBirthdayDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CBirthdayDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBirthdayDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	IsSetTimer=false;
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CBirthdayDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBirthdayDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CBirthdayDlg, CDialog)
	//{{AFX_MSG_MAP(CBirthdayDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_TIMER()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBirthdayDlg message handlers

BOOL CBirthdayDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

    CRgn m_rgn;
	CRect rec;
	GetClientRect(&rec);
	m_rgn.CreateEllipticRgn(rec.left,rec.top,rec.Width(),rec.Height());
    
 //	SetWindowRgn((HRGN)m_rgn,TRUE);

    PlaySound(MAKEINTRESOURCE(IDR_WAVE1),AfxGetResourceHandle(),SND_ASYNC|SND_RESOURCE|SND_NODEFAULT|SND_LOOP);

	m_distance = 30;
	m_bkbmpID=0;
    CString pArrCredit[NCLIP1] = { "祝:"
        ,"薛XX"
        ,"绝对菜鸟"     
        ,"佛剑分说"
        ,"三位Dota大神"
		,"生日快乐!"
        };
	bkbmpID[0]=IDB_BKBITMAP1;
    bkbmpID[1]=IDB_BKBITMAP2;
    bkbmpID[2]=IDB_BKBITMAP3;
    m_ftbitmap.LoadBitmap(IDB_BITMAP1);
	m_bkbitmap.LoadBitmap(bkbmpID[m_bkbmpID]);
	// Add "About..." menu item to system menu.
    CRect rect;
	GetClientRect(&rect);
	m_bkrec.left = int(rect.Width()*32/585);
	m_bkrec.top  = int(rect.Height()*56/392);
	m_bkrec.right = int(rect.Width()*555/585);
	m_bkrec.bottom = int(rect.Height()*335/392);
    SetCredits(pArrCredit);
	SetTimer(1,5,NULL);

	SetTimer(2,5000,NULL);
	IsSetTimer = true;
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CBirthdayDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CBirthdayDlg::OnPaint() 
{
    CPaintDC pdc(this);
	DrawDlg(&pdc);

	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		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;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CBirthdayDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CBirthdayDlg::DrawDlg(CDC *pDC)
{


    CRect rec;
	GetClientRect(&rec);

//	BITMAP bmp;
//	m_bitmap1.GetBitmap(&bmp);
//    pDC->SetStretchBltMode(HALFTONE);
//	pDC->StretchBlt(0,0,rec.Width(),rec.Height(),&cmpdc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);



	BITMAP bkbmp,ftbmp;
	m_bkbitmap.GetBitmap(&bkbmp);
	m_ftbitmap.GetBitmap(&ftbmp);
    CDC memDC;
	memDC.CreateCompatibleDC( pDC );
 
	CBitmap bitmap;
	bitmap.CreateCompatibleBitmap( pDC, ftbmp.bmWidth, ftbmp.bmHeight );
	CBitmap* pOldMemDCBitmap = memDC.SelectObject( &bitmap );
		
	CDC tempDC;
	tempDC.CreateCompatibleDC(pDC);
	CBitmap* pOldTempDCBitmap = tempDC.SelectObject( &m_ftbitmap);

	memDC.BitBlt( 0, 0, ftbmp.bmWidth, ftbmp.bmHeight , &tempDC, 
                      0,0, SRCCOPY );
	CDC maskDC;
	maskDC.CreateCompatibleDC(pDC);
	CBitmap maskBitmap;

	// Create monochrome bitmap for the mask
	maskBitmap.CreateBitmap( ftbmp.bmWidth, ftbmp.bmHeight , 1, 1, NULL );
	CBitmap* pOldMaskDCBitmap = maskDC.SelectObject( &maskBitmap );
    memDC.SetBkColor( RGB(192,192,192));

	// Create the mask from the memory DC
	maskDC.BitBlt( 0, 0,ftbmp.bmWidth, ftbmp.bmHeight , &memDC, 0, 0, SRCCOPY );

	tempDC.SelectObject(pOldTempDCBitmap);
	pOldTempDCBitmap = tempDC.SelectObject( &m_bkbitmap );

	CDC imageDC;
	CBitmap bmpImage;
	imageDC.CreateCompatibleDC( pDC );
	bmpImage.CreateCompatibleBitmap( pDC, rec.Width(), rec.Height() );
	CBitmap* pOldImageDCBitmap = imageDC.SelectObject( &bmpImage );

	// Get x and y offset
	// Draw bitmap in tiled manner to imageDC
	imageDC.SetStretchBltMode(HALFTONE);

	imageDC.StretchBlt( m_bkrec.left,m_bkrec.top,m_bkrec.Width(),m_bkrec.Height(), &tempDC, 0, 0, bkbmp.bmWidth,bkbmp.bmHeight,SRCCOPY );
 	imageDC.SetStretchBltMode(HALFTONE);
	imageDC.SetBkColor(RGB(255,255,255));
	imageDC.SetTextColor(RGB(0,0,0));

	AddFront(imageDC);

	// Set the background in memDC to black. Using SRCPAINT with black and any other
	// color results in the other color, thus making black the transparent color
	memDC.SetBkColor(RGB(0,0,0));
	memDC.SetTextColor(RGB(255,255,255));
	memDC.BitBlt(0, 0, ftbmp.bmWidth, ftbmp.bmHeight , &maskDC, 0, 0, SRCAND);
    
	// Set the foreground to black. See comment above.

	imageDC.StretchBlt(0,0, rec.Width(), rec.Height() , &maskDC, 0, 0,ftbmp.bmWidth,ftbmp.bmHeight, SRCAND);

	// Combine the foreground with the background
    imageDC.StretchBlt(0,0, rec.Width(),rec.Height(), &memDC, 0, 0, ftbmp.bmWidth, ftbmp.bmHeight,SRCPAINT);

	// Draw the final image to the screen   
	pDC->BitBlt( 0, 0, rec.Width(),rec.Height(),&imageDC, 0, 0, SRCCOPY );

	imageDC.SelectObject(pOldImageDCBitmap);
	maskDC.SelectObject(pOldMaskDCBitmap);
	tempDC.SelectObject(pOldTempDCBitmap);
	memDC.SelectObject(pOldMemDCBitmap);

}



void CBirthdayDlg::AddFront(CDC &dc)
{
	
    FrontDraw* p = pFD;
	int h;
	CFont* pOldFont;
	COLORREF OldColor;
	CRect r(m_bkrec);
	dc.SetBkMode(TRANSPARENT);
	while(p!=NULL)
	{
		if(!p->IsText)
		{
			if (m_mbitmap.m_hObject)
			{
				m_mbitmap.DeleteObject();
			}
			m_mbitmap.LoadBitmap(p->bmpID);
            h= p->m_rec.top;
			while((h>=m_bkrec.top-200) && (h<=m_bkrec.bottom))
			{
				BITMAP mbmp;
      
				m_mbitmap.GetBitmap(&mbmp);
				CDC memDC;
				memDC.CreateCompatibleDC(&dc );

				CBitmap bitmap;
				bitmap.CreateCompatibleBitmap( &dc, mbmp.bmWidth, mbmp.bmHeight );
				CBitmap* pOldMemDCBitmap = memDC.SelectObject( &bitmap );
					
				CDC tempDC;
				tempDC.CreateCompatibleDC(&dc);
				CBitmap* pOldTempDCBitmap = tempDC.SelectObject( &m_mbitmap);

				memDC.BitBlt( 0, 0, mbmp.bmWidth, mbmp.bmHeight , &tempDC, 
								  0,0, SRCCOPY );
				CDC maskDC;
				maskDC.CreateCompatibleDC(&dc);
				CBitmap maskBitmap;

				// Create monochrome bitmap for the mask
				maskBitmap.CreateBitmap( mbmp.bmWidth, mbmp.bmHeight , 1, 1, NULL );
				CBitmap* pOldMaskDCBitmap = maskDC.SelectObject( &maskBitmap );
				memDC.SetBkColor( RGB(192,192,192));

				// Create the mask from the memory DC
				maskDC.BitBlt( 0, 0,mbmp.bmWidth, mbmp.bmHeight , &memDC, 0, 0, SRCCOPY );

				// Set the background in memDC to black. Using SRCPAINT with black and any other
				// color results in the other color, thus making black the transparent color
				memDC.SetBkColor(RGB(0,0,0));
				memDC.SetTextColor(RGB(255,255,255));
				memDC.BitBlt(0, 0, mbmp.bmWidth, mbmp.bmHeight , &maskDC, 0, 0, SRCAND);

				// Set the foreground to black. See comment above.
				dc.StretchBlt(p->m_rec.left,h, p->m_rec.Width(), p->m_rec.Height() , &maskDC, 0, 0,mbmp.bmWidth,mbmp.bmHeight, SRCAND);

				// Combine the foreground with the background
				dc.StretchBlt(p->m_rec.left,h, p->m_rec.Width(),p->m_rec.Height(), &memDC, 0, 0, mbmp.bmWidth, mbmp.bmHeight,SRCPAINT);
				// Draw the final image to the screen   

				maskDC.SelectObject(pOldMaskDCBitmap);
				tempDC.SelectObject(pOldTempDCBitmap);
				memDC.SelectObject(pOldMemDCBitmap);
				h =NCLIP1*m_distance 480;
			}

		}
		else
		{
			h = p->m_height;

			if (p->m_font.m_hObject)
			   p->m_font.DeleteObject();
			pOldFont = dc.SelectObject(&(p->m_font));
			OldColor = dc.SetTextColor(p->TextColor);

			while((h>=m_bkrec.top-20) && (h<=m_bkrec.bottom))
			{
				r.top = h;
				dc.DrawText(p->m_str,p->m_str.GetLength(),&r,DT_TOP|DT_CENTER|DT_NOPREFIX | DT_SINGLELINE);
				h =NCLIP1*m_distance 480;
			}
			dc.SetTextColor(OldColor);
			dc.SelectObject(pOldFont);
		}
		p = p->next;
	}

}

void CBirthdayDlg::SetCredits(CString *pstr)
{
	CString *p;
	FrontDraw* q,*temp;
    CRect rect;
	GetClientRect(&rect);
	p=pstr;
	pFD = NULL;
	int Height = m_bkrec.bottom;
	q=new FrontDraw;
	q->IsText = false;
	q->m_rec.left = rect.left   (rect.Width()-200)/2;
	q->m_rec.right = q->m_rec.left   200;
	q->m_rec.top = Height;
	q->m_rec.bottom = Height 200;
	q->bmpID = IDB_FTBITMAP2;
	q->next = pFD;
	pFD = q;
	Height  = 250;
	for (int i=0; i<NCLIP1; i  )
	{
       q= new FrontDraw;
	   q->m_str=*p;
	   q->TextColor=RGB(0,0,255);
       q->m_font.CreateFont(15,8,0,0,0,0,0,0,0,0,0,0,0,"楷体");
	   q->m_height = Height;
       q->next = pFD;
	   pFD = q;
	   Height  =m_distance;
	   p = p 1;
	}
    q=new FrontDraw;
	q->IsText = false;
	q->m_rec.left = rect.left   (rect.Width()-150)/2;
	q->m_rec.right = q->m_rec.left   150;
	q->m_rec.top = Height;
	q->m_rec.bottom = Height 200;
	q->bmpID = IDB_FTBITMAP3;
	q->next = pFD;
	pFD = q;
}

void CBirthdayDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	FrontDraw* p = pFD;
    if (nIDEvent ==1)
	{
	 while(p!=NULL)
	 {
		  
       if (!p->IsText)
	   {
		   p->m_rec.top -=ST;
		   p->m_rec.bottom -=ST;
	       if (p->m_rec.top<m_bkrec.top-200)
		   {
             p->m_rec.top  =NCLIP1*m_distance 480;
			 p->m_rec.bottom  =NCLIP1*m_distance 480;
		   }
	   }
	   else
	   {
		   p->m_height -=ST;
		   if (p->m_height<m_bkrec.top-10)
		   {

			   p->m_height  =NCLIP1*m_distance 480;
		   }
	   }
	   p = p->next;
	 }
	}
	if (nIDEvent==2)
	{
		m_bkbmpID = (m_bkbmpID 1)%3;
		if(m_bkbitmap.m_hObject)
		{
			m_bkbitmap.DeleteObject();
		}
		m_bkbitmap.LoadBitmap(bkbmpID[m_bkbmpID]);
	}
	CClientDC dc(this);
	//Invalidate();
//	OnPaint();
	DrawDlg(&dc);
//	CDialog::OnTimer(nIDEvent);

}

void CBirthdayDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	if (IsSetTimer)
	{
		KillTimer(1);
		KillTimer(2);
	}
	// TODO: Add your message handler code here
	
}