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

📄 1.cpp

📁 用c++编写的代码
💻 CPP
字号:
#include<afxwin.h>
#define MAX_BUBBLE 250
class CMyWnd:public CFrameWnd
{
	CRect m_rectBubble[MAX_BUBBLE];
	int m_nBubbleCount;
public:
	CMyWnd(){m_nBubbleCount=0;}
protected:
	afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags,CPoint point);
    afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CMyWnd,CFrameWnd)
     ON_WM_LBUTTONDOWN()
     ON_WM_RBUTTONDOWN()
	 ON_WM_PAINT()
END_MESSAGE_MAP()
void CMyWnd::OnLButtonDown(UINT nFlags,CPoint point)
{
	if(m_nBubbleCount<MAX_BUBBLE)
	{
		int r=rand()%50+10;
		CRect rect(point.x-r,point.y-r,point.x+r,point.y+r);
		m_rectBubble[m_nBubbleCount]=rect;
		m_nBubbleCount++;
		InvalidateRect(rect,FALSE);
	}
}
void CMyWnd::OnPaint()
{
	CPaintDC dc(this);
	dc.SelectStockObject(LTGRAY_BRUSH);
	for(int i=0;i<m_nBubbleCount;i++)
		dc.Ellipse(m_rectBubble[i]);
}
void CMyWnd::OnRButtonDown(UINT nFlags,CPoint point)
{
	if(m_nBubbleCount<MAX_BUBBLE)
	{
		int r=rand()%50+10;
		CRect rect(point.x-r,point.y-r,point.x+r,point.y+r);
		m_rectBubble[m_nBubbleCount]=rect;
		m_nBubbleCount++;
		InvalidateRect(rect,FALSE);
	}
}
  
class CMyApp:public CWinApp
{
public:
	BOOL InitInstance();
};
BOOL CMyApp::InitInstance()
{
	CMyWnd *pFrame=new CMyWnd;
	pFrame->Create(0,_T("吹泡泡"));
	pFrame->ShowWindow(m_nCmdShow);
	this->m_pMainWnd=pFrame;
	return TRUE;
}
CMyApp ThisApp;

⌨️ 快捷键说明

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