⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello.cpp

📁 MFC Windows 程序设计源代码,有实用价值
💻 CPP
字号:
#include <afxwin.h>
#include "Hello.h"
#include <math.h>

#define SEGMENTS 500
#define PI 3.1415926

CMyApp myApp;

/////////////////////////////////////////////////////////////////////////
// CMyApp member functions

BOOL CMyApp::InitInstance ()
{
    m_pMainWnd = new CMainWindow;
    m_pMainWnd->ShowWindow (m_nCmdShow);
    m_pMainWnd->UpdateWindow ();
    return TRUE;
}

/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_LBUTTONDOWN()
ON_WM_PAINT ()
END_MESSAGE_MAP ()

CMainWindow::CMainWindow ()
{
    Create (NULL, _T ("The Hello Application"));
}

void CMainWindow::OnPaint ()
{
    /*
	CRect rect;
	GetClientRect(&rect);
	int nWidth = rect.Width();
	int nHeight = rect.Height();

	CPaintDC dc(this);
	CPoint aPoint[SEGMENTS];

	for(int i=0;i<SEGMENTS;i++)
	{
		aPoint[i].x=(i*nWidth)/SEGMENTS;
		aPoint[i].y=(int)((nHeight/2)*(1-(sin((2*PI*i)/SEGMENTS))));
	}
	dc.Polyline(aPoint,SEGMENTS);
	*/
	/*
	CPaintDC dc(this);
	int nRevenues[4] = {125,376,252,184};
	CRect rect;
	GetClientRect(&rect);
	dc.SetViewportOrg(rect.Width()/2,rect.Height()/2);

	int nTotal=0;
	for(int i=0;i<4;i++)
	{
		nTotal+=nRevenues[i];
	}

	int x1=0;
	int y1=-1000;
	int nSum=0;

	for(i=0;i<4;i++)
	{
		nSum+=nRevenues[i];
		double rad = ((double)(nSum*2*PI)/(double)nTotal)+PI;
		int x2 = (int)(sin(rad)*1000);
		int y2 = (int)(cos(rad)*1000*3)/4;
		dc.Pie(-200,-150,200,150,x1,y1,x2,y2);
		x1=x2;
		y1=y2;
	}
    */
	/*
	CRect rect;
	GetClientRect(&rect);

	CFont font;
	font.CreatePointFont(720,_T("Arial"));

	CPaintDC dc(this);
	dc.SelectObject(&font);
	dc.SetBkMode(TRANSPARENT);

	CString string = _T("Hello,MFC");

	rect.OffsetRect(16,16);
	dc.SetTextColor(RGB(192,192,192));
	dc.DrawText(string,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);

	rect.OffsetRect(-16,-16);
	dc.SetTextColor(RGB(0,0,0));
	dc.DrawText(string,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    */
	CRect rect;
	GetClientRect(&rect);

	CPaintDC dc(this);
	dc.SetViewportOrg(rect.Width()/2,rect.Height()/2);
	dc.SetBkMode(TRANSPARENT);
	for(int i=0;i<3600;i+=150)
	{
		LOGFONT lf;
		::ZeroMemory(&lf,sizeof(lf));
		lf.lfHeight=160;
		lf.lfWeight=FW_BOLD;
		lf.lfEscapement=i;
		lf.lfOrientation=i;
		::lstrcpy(lf.lfFaceName,_T("Arial"));

		CFont font;
		font.CreatePointFontIndirect(&lf);

		CFont * pOldFont = dc.SelectObject(&font);
		dc.TextOut(0,0,CString(_T("Hello,MFC")));
		dc.SelectObject(pOldFont);
	}
}
/*
void CMainWindow::OnLButtonDown(UINT nFlags, CPoint point)
{
	TRACE("杨力祥是全世界最笨的人!!!\n");
    TRACE("点击位置 - %d, %d\n", point.x, point.y);
}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -