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

📄 windowanima.cpp

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

			nSegOffset=0;
			nStepHeight=0;

			// repaint original screen to avoid animation trail.  Here
			// we only paint nDrop length of the segment which further
			// speeds up the process
			for(i=0;i<seg;i++){
				int hd=m_czWnd.cx+wx+nStepHeight-cumulator2;
				if(hd+m_czWnd.cx>0)
					m_pdcScreen->BitBlt(hd,wy+nSegOffset,step,segWidth,
						m_pdcMemScr,hd,wy+nSegOffset,SRCCOPY);
				nSegOffset+=segWidth;
				nStepHeight+=step;
			}
			cumulator+=step;
			cumulator2=cumulator;
		}
	}
}

/************************************************************************************
	Melts the window segment by segment towards the right of the screen
************************************************************************************/
void CWindowAnima::MeltRight(int nSegments, int nDrop, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int cumulator=0, cumulator2=0;
	int step=nDrop;

	int nVisibleLimit=m_czScr.cx-wx/step;

	int segWidth=m_czWnd.cy/nSegments;

	if(m_czWnd.cy%nSegments!=0)
		nSegments++;

	PrintWindow();

	for(int a=0;a<nVisibleLimit;a++){
		for(int seg=0;seg<nSegments;seg++){
			if(a>0)
				seg=nSegments;
			int nSegOffset=0;
			int nStepHeight=0;
			for(int i=0;i<seg;i++){
				int hd=wx+cumulator-nStepHeight;
				if(hd<=m_czScr.cx) {
					m_pdcScreen->BitBlt(hd,wy+nSegOffset,m_czWnd.cx,segWidth,
						m_pdcMemWnd,0,nSegOffset,SRCCOPY);
					Sleep(nSleeptime);
				}
				nSegOffset+=segWidth;
				nStepHeight+=step;
			}

			nSegOffset=0;
			nStepHeight=0;

			for(i=0;i<seg;i++){
				int hd=wx+cumulator2-nStepHeight;
				if(hd<=m_czScr.cx)
					m_pdcScreen->BitBlt(hd,wy+nSegOffset,step,segWidth,
						m_pdcMemScr,hd,wy+nSegOffset,SRCCOPY);
				nSegOffset+=segWidth;
				nStepHeight+=step;
			}
			cumulator2=cumulator;
			cumulator+=step;
		}
	}
}

/************************************************************************************
	Melts the window segment by segment towards the bottom of the screen
************************************************************************************/
void CWindowAnima::MeltDown(int nSegments, int nDrop, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int cumulator=0, cumulator2=0;
	int step=nDrop;

	int nVisibleLimit=((m_czScr.cy-wy)/step)+2;
	int segWidth=m_czWnd.cx/nSegments;

	if(m_czWnd.cx%nSegments!=0)
		nSegments++;

	PrintWindow();

	for(int a=0;a<nVisibleLimit;a++){
		for(int seg=0;seg<nSegments;seg++){
			if(a>0)
				seg=nSegments;
			int nSegOffset=0;
			int nStepHeight=0;
			for(int i=0;i<seg;i++){
				int hd=wy+cumulator-nStepHeight;
				if(hd<=m_czScr.cy) {
					m_pdcScreen->BitBlt(wx+nSegOffset,hd,segWidth,m_czWnd.cy,
						m_pdcMemWnd,nSegOffset,0,SRCCOPY);
					Sleep(nSleeptime);
				}
				nSegOffset+=segWidth;
				nStepHeight+=step;
			}

			nSegOffset=0;
			nStepHeight=0;

			for(i=0;i<seg;i++){
				int hd=wy+cumulator2-nStepHeight;
				if(hd<=m_czScr.cy)
					m_pdcScreen->BitBlt(wx+nSegOffset,hd, segWidth,step,
						m_pdcMemScr,wx+nSegOffset,hd,SRCCOPY);
				nSegOffset+=segWidth;
				nStepHeight+=step;
			}
			cumulator2=cumulator;
			cumulator+=step;
		}
	}
}

/************************************************************************************
	Melts the window segment by segment towards the top of the screen
************************************************************************************/
void CWindowAnima::MeltUp(int nSegments, int nDrop, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int cumulator=0, cumulator2=0;
	int step=nDrop;

	int nVisibleLimit=((m_rectWnd.bottom)/step)+3;
	int segWidth=m_czWnd.cx/nSegments;

	if(m_czWnd.cy%nSegments!=0)
		nSegments++;

	PrintWindow();

	for(int a=0;a<nVisibleLimit;a++){
		for(int seg=0;seg<nSegments;seg++){
			if(a>0)
				seg=nSegments;
			int nSegOffset=0;
			int nStepHeight=0;
			for(int i=0;i<seg;i++){
				int hd=wy+nStepHeight-cumulator;
				if(hd>=0-m_czWnd.cy) {
					m_pdcScreen->BitBlt(wx+nSegOffset,hd,segWidth,m_czWnd.cy,
						m_pdcMemWnd,nSegOffset,0,SRCCOPY);
					Sleep(nSleeptime);
				}
				nSegOffset+=segWidth;
				nStepHeight+=step;
			}

			nSegOffset=0;
			nStepHeight=0;

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

/************************************************************************************
	Returns the direction a window's top-left corner should take to reach the closest
	edge of the screen.
************************************************************************************/
int CWindowAnima::GetClosestSide()
{
	// check if position is closer to top edge than bottom edge
	int ClosestY=(m_rectWnd.top < (m_czScr.cy-m_rectWnd.top) ? 
		m_rectWnd.top : (m_czScr.cy-m_rectWnd.top));
	// check if position is closer to left edge than right edge
	int ClosestX=(m_rectWnd.left < (m_czScr.cx-m_rectWnd.left) ? 
		m_rectWnd.left : (m_czScr.cx-m_rectWnd.left));

	// check if postion is closer to a horizontal edge than a vertical edge
	if(ClosestX < ClosestY)
		return (ClosestX==m_rectWnd.left ? WA_LEFT : WA_RIGHT);
	else
		return (ClosestY==m_rectWnd.top ? WA_UP : WA_DOWN);
}

/************************************************************************************
	UnMelts the window segment by segment from the left of the screen to the right
************************************************************************************/
void CWindowAnima::UnMeltLeft(int nSegments, int nDrop, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nDrop;
	int cumulator=0-m_czWnd.cx;
	int cumulator2=cumulator-step;

	int segWidth=m_czWnd.cy/nSegments;

	if(m_czWnd.cy%nSegments!=0)
		nSegments++;

	int nVisibleLimit=((m_czWnd.cx+m_rectWnd.left)/step)+2;

	for(int a=0;a<nVisibleLimit;a++){
		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=cumulator-nStepHeight;
				if(hd<wx) {
					m_pdcScreen->BitBlt(hd,wy+nStepOffset,m_czWnd.cx,segWidth,
						m_pdcMemWnd,0,nStepOffset,SRCCOPY);
					Sleep(nSleeptime);
				} else {
					m_pdcScreen->BitBlt(wx,wy+nStepOffset,m_czWnd.cx,segWidth,
						m_pdcMemWnd,0,nStepOffset,SRCCOPY);
					Sleep(nSleeptime);						
				}
				nStepHeight+=step;
				nStepOffset+=segWidth;
			}

			nStepHeight=0;
			nStepOffset=0;

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

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

/************************************************************************************
	UnMelts the window segment by segment from the right of the screen to the left
************************************************************************************/
void CWindowAnima::UnMeltRight(int nSegments, int nDrop, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nDrop;
	int cumulator=m_czScr.cx-m_rectWnd.left;
	int cumulator2=cumulator-step;

	int segWidth=m_czWnd.cy/nSegments;

	if(m_czWnd.cy%nSegments!=0)
		nSegments++;

	int nVisibleLimit=((m_czScr.cx-m_rectWnd.left)/step)+1;

	for(int a=0;a<nVisibleLimit;a++){
		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=wx+cumulator+nStepHeight;
				if(hd>=wx) {
					m_pdcScreen->BitBlt(hd,wy+nStepOffset,m_czWnd.cx,segWidth,
						m_pdcMemWnd,0,nStepOffset,SRCCOPY);
					Sleep(nSleeptime);
				} else {
					m_pdcScreen->BitBlt(wx,wy+nStepOffset,m_czWnd.cx,segWidth,
						m_pdcMemWnd,0,nStepOffset,SRCCOPY);
					Sleep(nSleeptime);						
				}
				nStepHeight+=step;
				nStepOffset+=segWidth;
			}

			nStepHeight=0;
			nStepOffset=0;

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

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

/************************************************************************************
	UnMelts the window segment by segment from the bottom of the screen upwards
************************************************************************************/
void CWindowAnima::UnMeltUp(int nSegments, int nDrop, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nDrop;
	int cumulator=m_czScr.cy+m_rectWnd.top;
	int cumulator2=cumulator-step;

	int segWidth=m_czWnd.cx/nSegments;

	if(m_czWnd.cx%nSegments!=0)
		nSegments++;

	int nVisibleLimit=((m_czScr.cy+wy)/step)+2;

	for(int a=0;a<nVisibleLimit;a++){
		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-nStepHeight-cumulator;
				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=wy-cumulator2-nStepHeight;
				if(hd<=m_rectWnd.top)
					m_pdcScreen->BitBlt(wx+nStepOffset,hd,segWidth,step,
						m_pdcMemScr,wx+nStepOffset,hd,SRCCOPY);

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

/************************************************************************************
	UnMelts the window segment by segment from the top of the screen downwards
************************************************************************************/
void CWindowAnima::UnMeltDown(int nSegments, int nDrop, int nSleeptime)
{
	int wx=m_rectWnd.left, wy=m_rectWnd.top;
	int step=nDrop;
	int cumulator=m_czScr.cy-m_rectWnd.top;
	int cumulator2=cumulator-step;

	int segWidth=m_czWnd.cx/nSegments;

	if(m_czWnd.cx%nSegments!=0)
		nSegments++;

	int nVisibleLimit=((m_czScr.cy-wy)/step)+2;

	for(int a=0;a<nVisibleLimit;a++){

⌨️ 快捷键说明

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