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

📄 wndchild.h

📁 caro program is written by VC++ and AI
💻 H
字号:
/****************************************************************************/
//
// ~~~~~~~~~~~~~~~~ Window Child's Functions I ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//							WndChild.h
//
//***************************************************************************/



//////////////////////////////////////////////////////////////////////////////
// WndChild Size Message
void Child_Size()
{
RECT rect;

	// Get Window Child's size
	GetWindowSize(&WndChild);

	/********************************************************/
	// Set Scroll Info
	if(ec.iTab==ID_PLAY)
	{
		siH.cbSize	=	sizeof(siH);
		siH.fMask	=	SIF_ALL;
		siH.nMin	=	0;
		siH.nMax	=	setting.iBlock -1;
		siH.nPage	=	WndChild.xClient / XBLOCK;
		ec.iHodd	=	(WndPlay.xClient > WndChild.xClient) ? (WndChild.xClient % XBLOCK) / 2 : (WndChild.xClient - WndPlay.xClient) / 2;
		siH.nPos	=	play.siHPlay ;
		SetScrollInfo(WndChild.hWnd ,SB_HORZ,&siH,TRUE);
		siH.fMask=SIF_POS;
		GetScrollInfo(WndChild.hWnd ,SB_HORZ,&siH);
		play.siHPlay = siH.nPos ;
		
		siV.cbSize	=	sizeof(siV);
		siV.fMask	=	SIF_ALL;
		siV.nMin	=	0;
		siV.nMax	=	setting.iBlock -1;
		siV.nPage	=	WndChild.yClient / XBLOCK;
		ec.iVodd	=	(WndPlay.yClient > WndChild.yClient) ? (WndChild.yClient % XBLOCK) / 2 : (WndChild.yClient - WndPlay.yClient) / 2;
		siV.nPos	=	 play.siVPlay ;
		SetScrollInfo(WndChild.hWnd ,SB_VERT,&siV,TRUE);
		siV.fMask=SIF_POS;
		GetScrollInfo(WndChild.hWnd ,SB_VERT,&siV);
		play.siVPlay = siV.nPos ;

		// Get Window Play's size
		GetClientRect(WndPlay.hWnd,&rect) ;
		WndPlay.xClient = rect.right - rect.left ;
		WndPlay.yClient =rect.bottom -rect.top ;

		MoveWindow(WndPlay.hWnd , -siH.nPos * XBLOCK + ec.iHodd , - siV.nPos * XBLOCK + ec.iVodd , (setting.iBlock)* XBLOCK +1, (setting.iBlock)* XBLOCK +1, TRUE);

		// Get Window Play's size
		GetWindowSize(&WndPlay);
	}

	if(ec.iTab==ID_SETTING)
	{
		siV.cbSize=sizeof(siV);
		siV.fMask=SIF_ALL;
		siV.nMin=0;
		siV.nMax=DlgSetting.yClient / SETTING_STEP;
		siV.nPage=WndChild.yClient / SETTING_STEP;
		siV.nPos = ec.siVSetting;
		SetScrollInfo(WndChild.hWnd ,SB_VERT,&siV,TRUE);
		siV.fMask=SIF_POS;
		GetScrollInfo(WndChild.hWnd ,SB_VERT,&siV);
		
		MoveWindow(DlgSetting.hWnd , 0,- SETTING_STEP * siV.nPos ,DlgSetting.xClient , DlgSetting.yClient , TRUE);
	}
}

//////////////////////////////////////////////////////////////////////////////
// WndChild Paint Message
void Child_Paint()
{
HDC hDC;
PAINTSTRUCT ps;

	hDC=BeginPaint(WndChild.hWnd ,&ps);

	/******************************************/
	// If in Playing Mode
	if(ec.iTab == ID_PLAY)
	{
		// Get Window Play's size
		GetWindowSize(&WndChild);
		GetWindowSize(&WndPlay);

		// Show odd region
		MyRectangle(hDC, 0 , 0 , WndChild.xClient + 1 , max ( 0, WndPlay.top - WndChild.top ), skin.crBlockBorder , skin.crBlockBorder);
		MyRectangle(hDC, 0 , 0 , WndPlay.left - WndChild.left , WndChild.yClient , skin.crBlockBorder , skin.crBlockBorder);
		MyRectangle(hDC, WndPlay.right - WndChild.left , 0 , WndChild.xClient + 1 , WndChild.yClient , skin.crBlockBorder, skin.crBlockBorder);
		MyRectangle(hDC, 0, WndPlay.bottom - WndChild.top , WndChild.xClient +1 , WndChild.yClient , skin.crBlockBorder , skin.crBlockBorder);
	}

	/******************************************/
	// If in settings Mode
	if(ec.iTab == ID_SETTING)
	{
		MyRectangle(hDC, DlgSetting.xClient , 0, WndChild.xClient, WndChild.yClient, CR_CHILDBACK , CR_CHILDBACK ); // Fill background
		MyRectangle(hDC, 0 , DlgSetting.yClient - siV.nPos * SETTING_STEP, WndChild.xClient, WndChild.yClient, CR_CHILDBACK , CR_CHILDBACK ); // Fill background
	}

	/******************************************/
	// If in About Mode
	if(ec.iTab == ID_CREDIT)
	{
		MyRectangle(hDC, 0, 0, WndChild.xClient, WndChild.yClient, CR_CHILDBACK, CR_CHILDBACK); // Fill background
	}

	EndPaint(WndChild.hWnd , &ps);
}

//////////////////////////////////////////////////////////////////////////////
// WndChild VScroll Message
void Child_VScroll(WPARAM wParam)
{
int iOldPos;
RECT rect;
TCHAR szBuffer[50];

	siV.cbSize=sizeof(siV);
	siV.fMask=SIF_ALL;
	GetScrollInfo(WndChild.hWnd ,SB_VERT,&siV);
	iOldPos=siV.nPos ;
	
	switch(LOWORD(wParam))
	{
	case SB_TOP:
		siV.nPos = siV.nMin ;
		break;

	case SB_BOTTOM:
		siV.nPos = siV.nMax ;
		break;

	case SB_LINEUP:
		siV.nPos -= 1;
		break;

	case SB_LINEDOWN:
		siV.nPos += 1;
		break;

	case SB_PAGEUP:
		siV.nPos -= siV.nPage ;
		break;

	case SB_PAGEDOWN:
		siV.nPos += siV.nPage ;
		break;

	case SB_THUMBTRACK:
		siV.nPos=siV.nTrackPos;
		break;

	default:
		break;
	}

	siV.fMask =SIF_POS;
	SetScrollInfo(WndChild.hWnd , SB_VERT, &siV, TRUE);
	GetScrollInfo(WndChild.hWnd , SB_VERT, &siV);

	if(iOldPos!=siV.nPos )
	{
		// Scroll in Playing Mode
		if(ec.iTab == ID_PLAY) 
		{
			play.siVPlay = siV.nPos ;

			// Get Window Play's size
			GetClientRect(WndPlay.hWnd,&rect) ;
			WndPlay.xClient = rect.right - rect.left ;
			WndPlay.yClient =rect.bottom -rect.top ;

			MoveWindow(WndPlay.hWnd , -siH.nPos * XBLOCK + ec.iHodd , - siV.nPos * XBLOCK +ec.iVodd , WndPlay.xClient, WndPlay.yClient, TRUE);

			wsprintf(szBuffer,"[ %d - %d ] of %d",siV.nPos +1 , min( int(siV.nMax +1), int(siV.nPos + siV.nPage +1) ), siV.nMax +1);
			ShowStatus(szBuffer);
		}

		// Scroll in Setting Mode
		if(ec.iTab == ID_SETTING)
		{
			ec.siVSetting = siV.nPos ;
			MoveWindow(DlgSetting.hWnd , 0,- SETTING_STEP * siV.nPos ,DlgSetting.xClient , DlgSetting.yClient , TRUE);
		}
	}
	
}

//////////////////////////////////////////////////////////////////////////////
// WndChild HScroll Message
void Child_HScroll(WPARAM wParam)
{
int iOldPos;
RECT rect;
TCHAR szBuffer[50];

	siH.cbSize=sizeof(siH);
	siH.fMask=SIF_ALL;
	GetScrollInfo(WndChild.hWnd ,SB_HORZ,&siH);
	iOldPos=siH.nPos ;
	
	switch(LOWORD(wParam))
	{
	case SB_TOP:
		siH.nPos = siH.nMin ;
		break;

	case SB_BOTTOM:
		siH.nPos = siH.nMax ;
		break;

	case SB_LINELEFT:
		siH.nPos -= 1;
		break;

	case SB_LINERIGHT:
		siH.nPos += 1;
		break;

	case SB_PAGEUP:
		siH.nPos -= siH.nPage ;
		break;

	case SB_PAGEDOWN:
		siH.nPos += siH.nPage ;
		break;

	case SB_THUMBTRACK:
		siH.nPos=siH.nTrackPos;
		break;

	default:
		break;
	}
	
	siH.fMask =SIF_POS;
	SetScrollInfo(WndChild.hWnd , SB_HORZ, &siH, TRUE);
	GetScrollInfo(WndChild.hWnd , SB_HORZ, &siH);
	play.siHPlay = siH.nPos ;

	if(iOldPos!=siH.nPos )
	{
		// Get Window Play's size
		GetClientRect(WndPlay.hWnd,&rect) ;
		WndPlay.xClient = rect.right - rect.left ;
		WndPlay.yClient =rect.bottom -rect.top ;

		MoveWindow(WndPlay.hWnd , -siH.nPos * XBLOCK + ec.iHodd , - siV.nPos * XBLOCK +ec.iVodd , WndPlay.xClient, WndPlay.yClient, TRUE);

		wsprintf(szBuffer,"[ %d - %d ] of %d",siH.nPos +1 , min( int(siH.nMax +1), int(siH.nPos + siH.nPage +1)), siH.nMax +1);
		ShowStatus(szBuffer);

		InvalidateRect(WndPlay.hWnd, NULL, FALSE );
	}
	
}

//////////////////////////////////////////////////////////////////////////////
// WndChild Left Mouse Down Message
void Child_LButtonDown()
{
	MessageBeep(0);
}

⌨️ 快捷键说明

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