This code is designed for Birthday wish using VC++ based on MFC concepts
#include #include "resource.h"
class myframe:public CFrameWnd { public : myframe() { CString mywindowclass; HBRUSH b; b=::CreateSolidBrush(RGB(255,255,255)); mywindowclass=AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,AfxGetApp()->LoadCursorA(IDC_CURSOR1),b,AfxGetApp()->LoadIconA(IDI_ICON1)); Create(mywindowclass,"Birthday",WS_OVERLAPPEDWINDOW,CRect(10,10,400,500)); }
void OnPaint() { CPaintDC d(this); CRect r; GetClientRect(&r); CFont f; CBrush b; d.Rectangle(5,5,375,450);
d.SetTextColor(RGB(255,0,0)); d.TextOut(75,35,"H A P P Y B I R T H D A Y ",28); //Text Style f.CreateFontA(20,10,0,0,FW_BOLD,1,0,0,DEFAULT_CHARSET,0,0,0,0,"TimesNewRoman"); d.SelectObject(&f); //Color of the stars b.CreateSolidBrush(RGB(240,200,0)); d.SelectObject(b); POINT star1[]={40,54,50,25,60,54,38,37,65,37}; d.Polygon(star1,5); POINT star2[]={260,54,270,25,280,54,258,37,285,37}; d.Polygon(star2,5);
//Colors for the text d.SetTextColor(RGB(25,240,250)); d.TextOutA(45,90,"Dear ,",6);
d.SetTextColor(RGB(200,0,0)); d.TextOutA(130,130,"Wishing you health,",19);
d.SetTextColor(RGB(0,0,220)); d.TextOutA(145,156,"happiness and love",18);
d.SetTextColor(RGB(200,0,0)); d.TextOutA(132,180,"on your special day",19);
d.SetTextColor(RGB(0,0,220)); d.TextOutA(152,200,"and always !",12);
d.SetTextColor(RGB(220,0,200)); d.TextOutA(175,248,"Have a",6); d.TextOutA(150,266,"wonderful day",13);
d.SetTextColor(RGB(175,0,230)); d.TextOutA(240,330,"Always U'rs",11);
}
//Left Button of the mouse void OnLButtonDown(UINT flag,CPoint pt) { CClientDC d(this); d.SetTextColor(RGB(0,20,255)); d.TextOutA(pt.x,pt.y,"HAPPY BIRTHDAY",14); } DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(myframe,CFrameWnd) ON_WM_LBUTTONDOWN()
ON_WM_PAINT() END_MESSAGE_MAP()
class myapp:public CWinApp { public: int InitInstance() { myframe *p; p=new myframe; p->ShowWindow(1); m_pMainWnd=p; return 1; } }; myapp a;
For more details, visit http://www.happycodings.com/
|