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

📄 windowanima.cpp

📁 白云水库的电力管理系统包括界面处理
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		for(int seg=0;seg<nSegments;seg++){
			if(a>0)
				seg=nSegments;
			int nStepHeight=0;
			int nStepOffset=0;
			for(int i=0;i<seg;i++){
				int hd=wy+cumulator+nStepHeight;
				if(hd>=wy) {
					m_pdcScreen->BitBlt(wx+nStepOffset,hd,segWidth,m_czWnd.cy,
						m_pdcMemWnd,nStepOffset,0,SRCCOPY);
					Sleep(nSleeptime);
				} else {
					m_pdcScreen->BitBlt(wx+nStepOffset,wy,segWidth,m_czWnd.cy,
						m_pdcMemWnd,nStepOffset,0,SRCCOPY);
					Sleep(nSleeptime);						
				}
				nStepHeight+=step;
				nStepOffset+=segWidth;
			}

			nStepHeight=0;
			nStepOffset=0;

			for(i=0;i<seg;i++){
				int hd=cumulator2+nStepHeight+wy+m_czWnd.cy;
				if(hd>=m_rectWnd.bottom-step)
					m_pdcScreen->BitBlt(wx+nStepOffset,hd,segWidth,step,
						m_pdcMemScr,wx+nStepOffset,hd,SRCCOPY);

				nStepHeight+=step;
				nStepOffset+=segWidth;
			}
			cumulator-=step;
			cumulator2=cumulator-step;
		}
	}
}

/************************************************************************************
	Wipes the window into oblivion from right to left
************************************************************************************/
void CWindowAnima::WipeLeft(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;
	int nEndofWnd=m_rectWnd.right;

	// paint a copy of the window onto the screen
	PrintWindow();

	// while our leftside indicator has not reached
	// the right side, paint the area behind the window
	// over the image of the window thereby making it
	// disappear
	for(int i=wx;i<=nEndofWnd;i+=step){
		m_pdcScreen->BitBlt(i,wy, step,m_czWnd.cy,
			m_pdcMemScr, i, wy, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	Wipes the window into oblivion from left to right
************************************************************************************/
void CWindowAnima::WipeRight(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;
	int nStartofWnd=wx;

	PrintWindow();

	for(int i=m_rectWnd.right;i>=nStartofWnd;i-=step){
		m_pdcScreen->BitBlt(i,wy, step,m_czWnd.cy,
			m_pdcMemScr, i, wy, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	Wipes the window into oblivion from the top down
************************************************************************************/
void CWindowAnima::WipeDown(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;
	int nBaseofWnd=m_rectWnd.bottom;

	PrintWindow();

	for(int i=wy;i<=nBaseofWnd;i+=step){
		m_pdcScreen->BitBlt(wx,i, m_czWnd.cx,step,
			m_pdcMemScr,wx, i, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	Wipes the window into oblivion from the bottom up
************************************************************************************/
void CWindowAnima::WipeUp(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;
	int nTopofWnd=wy-step;

	PrintWindow();

	for(int i=m_rectWnd.bottom;i>=nTopofWnd;i-=step){
		m_pdcScreen->BitBlt(wx,i, m_czWnd.cx,step,
			m_pdcMemScr,wx, i, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	Chooses which Wipe animation to perform
************************************************************************************/
void CWindowAnima::Wipe(int nDirection, int nWipeFactor, int nSleeptime)
{
	// Do any pre-animation initialisations
	Initialise();

	if(nDirection==WA_RAND)
		nDirection=GetRandomDirection(6);

	switch(nDirection){
	case WA_LEFT:
		WipeLeft(nWipeFactor, nSleeptime);
		break;
	case WA_RIGHT:
		WipeRight(nWipeFactor, nSleeptime);
		break;
	case WA_UP:
		WipeUp(nWipeFactor, nSleeptime);
		break;
	case WA_DOWN:
		WipeDown(nWipeFactor, nSleeptime);
		break;
	case WA_HORZ:
		WipeHorz(nWipeFactor, nSleeptime);
		break;
	case WA_VERT:
		WipeVert(nWipeFactor, nSleeptime);
		break;
	}
}

/************************************************************************************
	UnWipes the window into view from left to right
************************************************************************************/
void CWindowAnima::UnWipeLeft(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	for(int i=0;i<=m_czWnd.cx;i+=step){
		m_pdcScreen->BitBlt(m_rectWnd.right-i,wy, step,m_czWnd.cy,
			m_pdcMemWnd, m_czWnd.cx-i, 0, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	UnWipes the window into view from right to left
************************************************************************************/
void CWindowAnima::UnWipeRight(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	for(int i=0;i<=m_czWnd.cx;i+=step){
		m_pdcScreen->BitBlt(wx+i,wy, step,m_czWnd.cy,
			m_pdcMemWnd, i, 0, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	UnWipes the window into view from the bottom up
************************************************************************************/
void CWindowAnima::UnWipeUp(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	for(int i=0;i<=m_czWnd.cx;i+=step){
		m_pdcScreen->BitBlt(wx,m_rectWnd.bottom-i, m_czWnd.cx,step,
			m_pdcMemWnd, 0, m_czWnd.cy-i, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	UnWipes the window into view from the top down
************************************************************************************/
void CWindowAnima::UnWipeDown(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	for(int i=0;i<=m_czWnd.cx;i+=step){
		m_pdcScreen->BitBlt(wx,wy+i, m_czWnd.cx,step,
			m_pdcMemWnd, 0, i, SRCCOPY);
		Sleep(nSleeptime);
	}
}

/************************************************************************************
	UnWipes the window into view from the top and bottom ends
************************************************************************************/
void CWindowAnima::UnWipeHorz(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	int nSplit=m_czWnd.cy/2;

	int i=nSplit;
	int j=nSplit;
	for(int k=0; k<nSplit; k+=step){
		m_pdcScreen->BitBlt(wx, wy+i,m_czWnd.cx,step,
			m_pdcMemWnd,0,i,  SRCCOPY);
		m_pdcScreen->BitBlt(wx, wy+j,m_czWnd.cx,step,
			m_pdcMemWnd,0,j,  SRCCOPY);
		Sleep(nSleeptime);
		i-=step;
		j+=step;
	}
}

/************************************************************************************
	UnWipes the window into view from the left and right sides
************************************************************************************/
void CWindowAnima::UnWipeVert(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	int nSplit=m_czWnd.cx/2;

	int i=nSplit;
	int j=nSplit;
	for(int k=0; k<nSplit; k+=step){
		m_pdcScreen->BitBlt(wx+i, wy,step,m_czWnd.cy,
			m_pdcMemWnd,i,0,  SRCCOPY);
		m_pdcScreen->BitBlt(wx+j, wy,step,m_czWnd.cy,
			m_pdcMemWnd,j,0,  SRCCOPY);
		Sleep(nSleeptime);
		i-=step;
		j+=step;
	}
}

/************************************************************************************
	Chooses which UnWipe animation to perform.
************************************************************************************/
void CWindowAnima::UnWipe(int nDirection, int nWipeFactor, 
						  int nSleeptime)
{
	// Do any pre-animation initialisations
	Initialise();

	if(nDirection==WA_RAND)
		nDirection=GetRandomDirection(6);

	switch(nDirection){
	case WA_LEFT:
		UnWipeLeft(nWipeFactor, nSleeptime);
		break;
	case WA_RIGHT:
		UnWipeRight(nWipeFactor, nSleeptime);
		break;
	case WA_UP:
		UnWipeUp(nWipeFactor, nSleeptime);
		break;
	case WA_DOWN:
		UnWipeDown(nWipeFactor, nSleeptime);
		break;
	case WA_HORZ:
		UnWipeHorz(nWipeFactor, nSleeptime);
		break;
	case WA_VERT:
		UnWipeVert(nWipeFactor, nSleeptime);
		break;
	}

	RestoreWindow(FALSE);
}

/************************************************************************************
	Wipes the window into oblivion from the top and bottom ends
************************************************************************************/
void CWindowAnima::WipeHorz(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	PrintWindow();

	// add on an extra iteration to make sure it all fully
	// disappears
	int nSplit=(m_czWnd.cy/2)+step;

	int i=m_rectWnd.bottom;
	int j=m_rectWnd.top;
	for(int k=0; k<=nSplit; k+=step){
		m_pdcScreen->BitBlt(wx,i, m_czWnd.cx,step,
			m_pdcMemScr,wx, i, SRCCOPY);
		m_pdcScreen->BitBlt(wx,j, m_czWnd.cx,step,
			m_pdcMemScr,wx, j, SRCCOPY);
		Sleep(nSleeptime);
		i-=step;
		j+=step;
	}
}

/************************************************************************************
	Wipes the window into oblivion from the left and right sides.
************************************************************************************/
void CWindowAnima::WipeVert(int nWipeFactor, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nWipeFactor;

	PrintWindow();

	// add on an extra iteration to make sure it all fully
	// disappears
	int nSplit=(m_czWnd.cx/2)+step;

	int i=m_rectWnd.right;
	int j=m_rectWnd.left;
	for(int k=0; k<=nSplit; k+=step){
		m_pdcScreen->BitBlt(i, wy,step,m_czWnd.cy,
			m_pdcMemScr,i,wy,  SRCCOPY);
		m_pdcScreen->BitBlt(j, wy,step,m_czWnd.cy,
			m_pdcMemScr,j,wy,  SRCCOPY);
		Sleep(nSleeptime);
		i-=step;
		j+=step;
	}
}

/************************************************************************************
	Grab a copy of the screen that another CWindowAnima object has gone to all the
	trouble of capturing.  Make sure (in debug mode) that some idiot hasn't passed
	us a pointer to an CWindowAnima object that hasn't got a screen image.
************************************************************************************/
BOOL CWindowAnima::CopyScreenCapture(CWindowAnima *pWA)
{
	ASSERT(pWA->m_pdcMemScr!=NULL);
	return InjectScreenImage(pWA->m_pdcMemScr);
}

/************************************************************************************
	Copy the image from the CDC object pointed to by pdcMemWnd into our member
	DC object m_dcMemWnd and update our member variables describing the windows
	position and size;
************************************************************************************/
BOOL CWindowAnima::InjectWindowImage(CDC *pdcMemWnd, CRect *prectWnd)
{
	CBitmap bmWindow;

	// get the width and height of the window in the other CWindowAnima object
	m_czWnd.cx=prectWnd->Width();
	m_czWnd.cy=prectWnd->Height();

	// copy it's position and size
	m_rectWnd.CopyRect(prectWnd);

	// remove our old window image if we had one
	if(m_pdcMemWnd!=NULL){
		m_pdcMemWnd->SelectObject(m_pOldBitmapWnd);
		delete m_pdcMemWnd;
	}

	m_pdcMemWnd=new CDC;

	bmWindow.CreateCompatibleBitmap(pdcMemWnd,m_czWnd.cx,m_czWnd.cy);

	m_pdcMemWnd->CreateCompatibleDC(pdcMemWnd);
	m_pOldBitmapWnd=m_pdcMemWnd->SelectObject(&bmWindow);

	// copy the window image from the other CWindowAnima object into our own
	// offscreen window image memory
	return m_pdcMemWnd->BitBlt(0,0,m_czWnd.cx,m_czWnd.cy,pdcMemWnd,0,0,SRCCOPY);
}

/************************************************************************************
	Replace a window's image and size with an image resource identified by
	nResID.  Useful if you wanted to animate the initial appearance of a window

⌨️ 快捷键说明

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