📄 test.cpp
字号:
// test.cpp: implementation of the test class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Hospital.h"
#include "test.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
test::test()
{
m_bitmap.LoadBitmap(IDB_BITMAP5);//拷贝资源位图
m_bitmap.GetBitmap(&bm);//得到位图结构中的大小信息
}
test::~test()
{
}
BEGIN_MESSAGE_MAP(test, CWnd)
//{{AFX_MSG_MAP(CLjxWnd)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void test::CreatLjxWnd()
{
//建立大小与位图大小相同的窗口
CreateEx(0,
AfxRegisterWndClass(0,AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
"animatesplash",
WS_POPUP,
0,0,bm.bmWidth,bm.bmHeight,
NULL,
NULL,
NULL );
}
void test::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
MemDC.CreateCompatibleDC(NULL);//建立一个和dc兼容的内存DC放置位图
old_bitmap=MemDC.SelectObject(&m_bitmap);//将创建的位图选入内存DC
int i,j,stepx,stepy,dispnum,x,y;
int ljx[20][20]; //数组记录已显示过的数据组
for ( i=0; i<20; i++ )
for ( j=0; j<20; j++ )
ljx[i][j]=0;
stepx=bm.bmWidth/20;
stepy=bm.bmHeight/20;
srand( (unsigned)time( NULL ) );
dispnum=0;
//记录已显示过的数据组的个数
while(1)
{
x=rand() % 20;
y=rand() % 20;
if ( ljx[x][y] ) //如果为1,则已经显示了,跳出循环。
continue;
ljx[x][y]=1; //显示,设置为1
dc.StretchBlt(
x*stepx, y*stepy,stepx,stepy,&MemDC,x*stepx, y*stepy,stepx,stepy,SRCCOPY);
dispnum++;
if(dispnum >=400 )
break;
Sleep(10);
}
MemDC.SelectObject(old_bitmap);
// Do not call CWnd::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -