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

📄 interface.cpp

📁 tcpmp 中修改过的界面文件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	node* Format;
	
	p->Player->Set(p->Player,PLAYER_LIST_CURRENT,&i,sizeof(i));
	
	// only play when loading succeeded
	if (p->Player->Get(p->Player,PLAYER_FORMAT,&Format,sizeof(Format)) == ERR_NONE && Format)
	{
		b = 1;
		p->Player->Set(p->Player,PLAYER_PLAY,&b,sizeof(b));
	}
}

//#define LBS_OWNERDRAWFIXED    0x0010L

//创建列表子窗口
static void CreatePlayListWnd(intface* p)
{	p->Win.ToolBarHeight=0; //临时
	if (QueryPlatform(PLATFORM_TYPENO) != TYPE_SMARTPHONE)
	{
		WNDCLASS WinClass;

		memset(&WinClass,0,sizeof(WinClass));
		WinClass.style			= CS_HREDRAW | CS_VREDRAW;
		WinClass.lpfnWndProc	= (WNDPROC) PlayListWndProc;
		WinClass.cbClsExtra		= 0;
		WinClass.cbWndExtra		= 0;
		WinClass.hInstance		= (HINSTANCE)p->Win.Module;
		WinClass.hCursor		= (HICON)WinCursorArrow();
		WinClass.hbrBackground	= GetSysColorBrush(COLOR_BTNFACE);
		WinClass.lpszMenuName	= 0;
		WinClass.lpszClassName	= T("PlayListWnd");
		RegisterClass(&WinClass);
		
		p->WndPlayList = CreateWindowEx( 
			0,                    
			_T("LISTBOX"),//_T("SysListView32"),       
			NULL,   
			//为什么加上LBS_MULTIPLESEL风格后, SetTopIndex方法无效???????? zy/2007/03/16
			WS_CHILD | LBS_NOTIFY | LBS_HASSTRINGS | LBS_NOREDRAW, //WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_HASSTRINGS, 
			0, 0, 0, 0, //0, 0, 40, 20,   
			(HWND)p->Win.Wnd, //p->WndVolBack,  //临时
			(HMENU)IDC_LIST_PLAYLIST, //NULL,						
			(HINSTANCE)p->Win.Module,                     
			NULL                      
			); 

		p->DefPlayListProc = (WNDPROC)GetWindowLong(p->WndPlayList,GWL_WNDPROC);
		SetWindowLong(p->WndPlayList,GWL_WNDPROC,(LONG)PlayListWndProc);
		WinSetObject(p->WndPlayList,&p->Win);

		//SendMessage(p->WndPlayList, TBM_SETRANGE, FALSE,MAKELONG(0,100));
		//SendMessage(p->WndPlayList, TBM_SETPAGESIZE,0,10);
		//SendMessage(p->WndPlayList, TBM_SETLINESIZE,0,10);

		//ResizeVolume(p);
		//UpdateVolume(p);
	}
}

// 令播放列表下滚
static void DoPlayListUp(intface* p)
{
//	AfxMessageBox(_T("Up"));
	ASSERT(p);
	if( p->WndPlayList ) {
		int nTopIndex = ListBox_GetTopIndex(p->WndPlayList);
		if( nTopIndex>0 ) {
			//nTopIndex--;
			//改翻屏
			nTopIndex -= p->pPlayListbox->GetPageItemCount()-1; 
			if( nTopIndex<0 ) {
				nTopIndex = 0;
			}
			ListBox_SetTopIndex(p->WndPlayList, nTopIndex);
		}
		::InvalidateRect( p->WndPlayList, NULL, FALSE );		
	}
}

// 令播放列表上滚
static void	DoPlayListDown(intface* p)
{
//	AfxMessageBox(_T("Down"));
	ASSERT(p);
	if( p->WndPlayList ) {
		int nTopIndex = ListBox_GetTopIndex(p->WndPlayList);
		int nCount = ListBox_GetCount(p->WndPlayList);
		if( nTopIndex<(nCount-1) ) {
			//nTopIndex++;
			//改翻屏
			nTopIndex += p->pPlayListbox->GetPageItemCount()-1; 
			if( nTopIndex>=(nCount-1) ) {
				nTopIndex = nCount-1;//-p->pPlayListbox->GetPageItemCount()-1;
			}
			ListBox_SetTopIndex(p->WndPlayList, nTopIndex);
		}
		::InvalidateRect( p->WndPlayList, NULL, FALSE );		
	}
}

// 删除播放列表中选定项
static void DoPlayListRemove(intface* p)
{
	ASSERT(p);
	if( p->WndPlayList ) {
		int nCurSel = ListBox_GetCurSel(p->WndPlayList);
		if( nCurSel>=0 ) {
			int nCurPlay;
			p->Player->Get(p->Player,PLAYER_LIST_CURRENT,&nCurPlay,sizeof(nCurPlay));

			if( nCurPlay==nCurSel ) {
				//打开下一媒体
				p->Player->Set(p->Player,PLAYER_NEXT,NULL,0);
			}			
			//要播放器移去选择项
			int nPLCount;
			if (p->Player->Get(p->Player,PLAYER_LIST_COUNT,&nPLCount,sizeof(nPLCount))==ERR_NONE) {
				for (int i=nCurSel; i<nPLCount-1; ++i) {
					p->Player->ListSwap(p->Player, i, i+1);
				}

				--nPLCount;
				
				//if (p->Pos>n || p->Pos>=nPLCount) {
				//	--p->Pos;
				//}
				
				p->Player->Set(p->Player,PLAYER_LIST_COUNT,&nPLCount,sizeof(nPLCount));
			}
			
			if (p->Player->Get(p->Player,PLAYER_LIST_COUNT,&nPLCount,sizeof(nPLCount))==ERR_NONE) {
				if( nPLCount==0 ) {
					//p->Player->Set(p->Player,PLAYER_STOP,NULL,1); // full stop (no filling buffers)
					SendMessage( (HWND)p->Win.Wnd, WM_COMMAND, IF_STOP, 0L );
				}
			}
		}

		UpdatePlayList(p);
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		
//装入Skin资源
static bool LoadSkin(intface* p)
{	
	TCHAR Path[MAXPATH];
	GetModulePath(Path, NULL);
	_tcscat(Path, _T("vmaxplayer.ini"));
	
	//	AfxMessageBox( Path );
	p->pIni->SetIniPath( Path );
	CString sSkinFile = p->pIni->GetProfileString( _T("Option"), _T("Skin") );
	if( sSkinFile.IsEmpty() ) {
		return FALSE;
	}
	
	CString sT;
	GetModulePath(Path, NULL);
	sT.Format( _T("%s%s"), Path, sSkinFile );
	p->paSkin->SetIniPath( sT );
	//p->paSkin->SetIniPath( sSkinFile );
	
	//取目录
	CString sSkinPath;
	int n = sT.ReverseFind(_T('\\'));
	if( n>=0 ) {
		sSkinPath = sT.Left(n+1);	//包括斜杠
	}
	if( sSkinPath.IsEmpty() ) {
		return FALSE;
	}
	
	CString sImgFile;
	CString sFull;

	CImage* pImgTemp[6];
	pImgTemp[0]=pImgTemp[1]=pImgTemp[2]=pImgTemp[3]=pImgTemp[4]=pImgTemp[5]=NULL;

	sImgFile = p->paSkin->GetProfileString( _T("MAIN_WND"), _T("imgN") );
	ASSERT(!sImgFile.IsEmpty());
	sFull = sSkinPath + sImgFile;
	BOOL b = p->m_pimgState[0]->CreateFromFile( sFull, ENUM_cimage_format_jpeg );	//normal
	ASSERT(b);
	if( b ) {
		pImgTemp[0]=p->m_pimgState[0];
	}

	sImgFile = p->paSkin->GetProfileString( _T("MAIN_WND"), _T("imgH") );
	ASSERT(!sImgFile.IsEmpty());
	sFull = sSkinPath + sImgFile;
	b = p->m_pimgState[1]->CreateFromFile( sFull, ENUM_cimage_format_jpeg );	//hilight
	ASSERT(b);
	if( b ) {
		pImgTemp[1]=p->m_pimgState[1];
	}
	
	sImgFile = p->paSkin->GetProfileString( _T("MAIN_WND"), _T("imgF") );
	if( !sImgFile.IsEmpty() ) {
		sFull = sSkinPath + sImgFile;
		b = p->m_pimgState[2]->CreateFromFile( sFull, ENUM_cimage_format_jpeg );	//focus
		if( b ) {
			pImgTemp[2]=p->m_pimgState[2];
		}
	}

	sImgFile = p->paSkin->GetProfileString( _T("MAIN_WND"), _T("imgD") );
	if( !sImgFile.IsEmpty() ) {
		sFull = sSkinPath + sImgFile;
		b = p->m_pimgState[3]->CreateFromFile( sFull, ENUM_cimage_format_jpeg );	//disabled	
		if( b ) {
			pImgTemp[3]=p->m_pimgState[3];
		}
	}
	
	sImgFile = p->paSkin->GetProfileString( _T("MAIN_WND"), _T("imgM") );
	if( !sImgFile.IsEmpty() ) {
		sFull = sSkinPath + sImgFile;
		p->m_pimgState[4]->CreateFromFile( sFull, ENUM_cimage_format_jpeg );	//Mask bitmap	
		if( b ) {
			pImgTemp[4]=p->m_pimgState[4];
		}
	}
	
	sImgFile = p->paSkin->GetProfileString( _T("MAIN_WND"), _T("imgOther") );
	if( !sImgFile.IsEmpty() ) {
		sFull = sSkinPath + sImgFile;
		p->m_pimgState[5]->CreateFromFile( sFull, ENUM_cimage_format_jpeg );	//Other bitmap	
		if( b ) {
			pImgTemp[5]=p->m_pimgState[5];
		}
	}
	
	//为Button设置图片
	CRect rcSel;

	//图片显示区, (l, t, 宽度, 高度), 所以要调整
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_DISPAREA"), _T("Position") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	p->DispAreaRect = (RECT)rcSel;
	p->DispAreaRect.right += rcSel.left;
	p->DispAreaRect.bottom += rcSel.top;

	sImgFile = p->paSkin->GetProfileString( _T("IDW_MAIN_DISPAREA"), _T("imgLogo") );
	if( !sImgFile.IsEmpty() ) {
		sFull = sSkinPath + sImgFile;
		//MessageBox((HWND)p->Win.Wnd,sFull,LangStr(PLATFORM_ID,PLATFORM_ERROR),MB_OK|MB_SETFOREGROUND|MB_TOPMOST);		
		p->m_pimgDispAreaBg->CreateFromFile( sFull, ENUM_cimage_format_jpeg );	//播放区背景图		
	}

	//TitleTime控件位置
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_TITLETIME"), _T("Position") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	p->rtTitle = (RECT)rcSel;
	p->rtTitle.right += rcSel.left;
	p->rtTitle.bottom += rcSel.top;

	//播放列表控件位置
	sT = p->paSkin->GetProfileString( _T("IDW_LISTBOX_PLAYLIST"), _T("Position") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	p->rtPlayList = (RECT)rcSel;
	p->rtPlayList.right += rcSel.left;
	p->rtPlayList.bottom += rcSel.top;

	CRect rcFocused;   //当前行底图
	sT = p->paSkin->GetProfileString( _T("IDW_LISTBOX_PLAYLIST"), _T("FocusedPos") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcFocused.left, &rcFocused.top, &rcFocused.right, &rcFocused.bottom );

	p->pPlayListbox->SetBitmaps(  pImgTemp[0], pImgTemp[1], pImgTemp[2], pImgTemp[3], pImgTemp[4], rcSel, rcFocused );
	
	////////////////////////////////////////////////////////////////////////////////////////////
	//Track控件位置
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_TRACK"), _T("Position") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	p->rtTrack = (RECT)rcSel;
	p->rtTrack.right += rcSel.left;
	p->rtTrack.bottom += rcSel.top;

	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_TRACK"), _T("ChannelPos") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	RECT rcChannel;
	rcChannel = (RECT)rcSel;

	//轨道左侧
	RECT rcChannelA;
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_TRACK"), _T("ChannelPosA") );
	if( !sT.IsEmpty() ) {
		_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
		rcChannelA = (RECT)rcSel;
	} else {
		rcChannelA.left = rcChannelA.right = rcChannelA.top = rcChannelA.bottom = 0;
	}
	
	//轨道右侧
	RECT rcChannelN;
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_TRACK"), _T("ChannelPosN") );
	if( !sT.IsEmpty() ) {
		_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
		rcChannelN = (RECT)rcSel;
	} else {
		rcChannelN.left = rcChannelN.right = rcChannelN.top = rcChannelN.bottom = 0;
	}

	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_TRACK"), _T("ThumbPos") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	RECT rcThumb;
	rcThumb = (RECT)rcSel;
	
	p->pTrackSlider->SetBitmaps(  pImgTemp[0], pImgTemp[1], pImgTemp[2], pImgTemp[3], pImgTemp[4], pImgTemp[5], rcChannel, rcThumb, rcChannelA, rcChannelN );
	////////////////////////////////////////////////////////////////////////////////////////////////////

	//Volume控件位置
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_VOLUME"), _T("Position") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	p->rtVol = (RECT)rcSel;
	p->rtVol.right += rcSel.left;
	p->rtVol.bottom += rcSel.top;

	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_VOLUME"), _T("ChannelPos") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	rcChannel = (RECT)rcSel;
	
	//轨道左侧
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_VOLUME"), _T("ChannelPosA") );
	if( !sT.IsEmpty() ) {
		_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
		rcChannelA = (RECT)rcSel;
	} else {
		rcChannelA.left = rcChannelA.right = rcChannelA.top = rcChannelA.bottom = 0;
	}
	
	//轨道右侧
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_VOLUME"), _T("ChannelPosN") );
	if( !sT.IsEmpty() ) {
		_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
		rcChannelN = (RECT)rcSel;
	} else {
		rcChannelN.left = rcChannelN.right = rcChannelN.top = rcChannelN.bottom = 0;
	}
	
	sT = p->paSkin->GetProfileString( _T("IDW_MAIN_VOLUME"), _T("ThumbPos") );
	_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
	rcThumb = (RECT)rcSel;
	
	p->pVolSlider->SetBitmaps(  pImgTemp[0], pImgTemp[1], pImgTemp[2], pImgTemp[3], pImgTemp[4], pImgTemp[5], rcChannel, rcThumb, rcChannelA, rcChannelN );
	////////////////////////////////////////////////////////////////////////////////////////////////////
	
	for( int i=0; i<MAX_BUTTONS; i++ ) {
		sT = p->paSkin->GetProfileString( (CString)ga_ButtonInfos[i].pCaption, _T("Position") );
		if( sT.IsEmpty() ) {
			//rcSel = CRect(60,200,30,30);
			//ShowMessage(_T("Skins"), _T("Button position not set!"));
			rcSel = CRect(0,0,0,0);
		} else {
			_stscanf( sT, _T("%d,%d,%d,%d"), &rcSel.left, &rcSel.top, &rcSel.right, &rcSel.bottom );
		}
		//p->ga_pSkinBtns[i]->SetBitmaps( pImgTemp[0], pImgTemp[1], pImgTemp[2], pImgTemp[3], pImgTemp[4], rcSel );
		p->ga_pSkinBtns[i]->SetBitmaps( pImgTemp[0], pImgTemp[1], NULL, NULL, NULL, rcSel );
	}

	return TRUE;
}

static void ResizeVolume(intface* p)
{	return;	///临时取消
	if (p->WndVolBack)
	{
		RECT rv;
		RECT r;
		POINT o;
		int Width;
		int i;

		GetClientRect((HWND)p->Win.WndTB,&r);
		if (r.left<r.right)
		{
			SendMessage((HWND)p->Win.WndTB,TB_GETRECT,IF_OPTIONS_MUTE,(LPARAM)&rv);

#if defined(TARGET_WINCE)
			if (p->Win.ToolBarHeight) // decrease width by 'X' button on right
				r.right = max(r.left,r.right-(rv.right-rv.left));
#endif

			Width = r.right-rv.right;
			if (Width < 16)
				Width = 16;

			i = WinUnitToPixelX(&p->Win,50);
			if (Width > i)
				Width = i;

			o.x = o.y = 0;
			if (!p->Win.ToolBarHeight)
				ClientToScreen((HWND)p->Win.WndTB,&o);

			MoveWindow(p->WndVolBack,rv.right+o.x,o.y+1,Width,r.bottom-1,TRUE);

			GetClientRect(p->WndVolBack,&r);
			i = WinUnitToPixelX(&p->Win,2);
			MoveWindow(p->WndVol,-i,0,r.right+2*i,r.bottom,TRUE);

			SendMessage(p->WndVol, TBM_SETTHUMBLENGTH,WinUnitToPixelY(&p->Win,VOLTHUMB),0);
		}
	}
}

static bool_t Toggle(intface* p,int Param,int Force);
static void UpdateVolume(intface* p);
static void UpdateClipping(intface* p,bool_t Suggest,bool_t HotKey);

static void ShowVol(intface* p,bool_t Show)
{
/*
	if (p->WndVolBack && !p->Win.ToolBarHeight)
	{
		if (Show)
			SetWindowPos(p->WndVolBack,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
		else
			ShowWindow(p->WndVolBack,SW_HIDE);

		if (p->VolResizeNeeded2>1)
			p->VolResizeNeeded2=1;

	}
*/
	if (p->WndVol && !p->Win.ToolBarHeight)
	{
		if (Show)
			SetWindowPos(p->WndVol,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
		else
			ShowWindow(p->WndVol,SW_HIDE);
		
		if (p->VolResizeNeeded2>1)
			p->VolResizeNeeded2=1;		
	}
}

static void ShowSkinButtons(intface* p,bool_t Show)
{
//	SendMessage( (HWND)p->Win.Wnd, WM_SETREDRAW, FALSE, 0 );
	if( Show ) {
		UpdatePlayList(p);

		InvalidateRect( (HWND)p->Win.Wnd, NULL, FALSE );
		
		int nNumChilds = 4 + MAX_BUTTONS;
		HDWP hDwp = ::BeginDeferWindowPos( nNumChilds );
		
//		SetWindowPos( p->WndTitle,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
//		SetWindowPos( p->WndTrack,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
//		SetWindowPos( p->WndVol,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
//		SetWindowPos( p->WndPlayList,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_SHOWWINDOW);

⌨️ 快捷键说明

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