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

📄 playlist.cpp

📁 在wince下面开发的一个图片浏览器全部用图形界面编写的,带图片放大缩小,图片拖动,图片自动播放等功能,支持jpg,bmp格式. 图片缩放始终保持原始比例,
💻 CPP
字号:
// Playlist.cpp: implementation of the CPlaylist class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ImageViewer.h"
#include "Playlist.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPlaylist::CPlaylist()
{
	m_CurrentFile = 0;
	m_TotalFiles = 0;
	m_FileList.RemoveAll();
	m_FilePath = L"";
}

CPlaylist::~CPlaylist()
{

}

CString CPlaylist::GetNextWorkFileName(bool bForword, bool bRandom)
{
	if (bRandom)		// 随机获取
	{
		// 计算随机数
		MakeRandom(m_CurrentFile);
		if (m_CurrentFile < m_TotalFiles - 1)
		{
			m_CurrentFile++;
		} 
		else
		{
			m_CurrentFile = 0;
		}
	}
	else
	{
		if (bForword)			// 前一个文件
		{
			if (m_CurrentFile > 0)
			{
				m_CurrentFile--;
			} 
			else
			{
				m_CurrentFile = m_TotalFiles - 1;
			}
		} 
		else			// 后一个文件
		{
			if (m_CurrentFile < m_TotalFiles - 1)
			{
				m_CurrentFile++;
			} 
			else
			{
				m_CurrentFile = 0;
			}
		}
	}
	return m_FilePath + m_FileList.GetAt(m_CurrentFile);
}

unsigned int CPlaylist::MakeRandom(int MaxNumber)
{
	return m_Seed[MaxNumber];
}

void CPlaylist::InitSeed(int iNumber)
{
	ZeroMemory(m_Seed,1024);
	unsigned* iValue = (unsigned*)calloc(iNumber,sizeof(unsigned));
	int k = 0;
	int tmp = 0;
	for (int j = 0; j < iNumber; j++)
	{
		iValue[j] = j;
	}

	for (int i = 0; i < iNumber; i++)
	{
		srand(Random());
		k = rand() % iNumber;
		tmp = iValue[k];
		iValue[k] = iValue[iNumber - k -1];
		iValue[iNumber - k -1] = tmp;
	}

	CopyMemory(m_Seed,iValue,iNumber * 4);
	ZeroMemory(iValue,iNumber);
}

⌨️ 快捷键说明

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