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

📄 selectfilelist.cpp

📁 COM 组建的开发
💻 CPP
字号:
// SelectFileList.cpp: implementation of the CSelectFileList class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"
#include "SelectFileList.h"

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

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

CSelectFileList::CSelectFileList()
{
	hMutex = CreateMutex(NULL,FALSE,NULL);
}

CSelectFileList::~CSelectFileList()
{

}
// 添加一个选择的文件 [5/6/2008 By willing]
BOOL CSelectFileList::AddItem(CSelectFile SelectFile)
{
	DWORD dwRe = WaitForSingleObject(hMutex,LIST_TIME_OUT);
	if (dwRe != WAIT_TIMEOUT)
	{
		selFileList.AddTail(SelectFile);

		ReleaseMutex(hMutex);
		return TRUE;
	}
	return FALSE;
}
// 清空链表 [5/6/2008 By willing]
BOOL CSelectFileList::RemoveAll()
{
	DWORD dwRe = WaitForSingleObject(hMutex,LIST_TIME_OUT);
	if (dwRe != WAIT_TIMEOUT)
	{
		selFileList.RemoveAll();
		ReleaseMutex(hMutex);
		return TRUE;
	}
	return FALSE;
}
// 获取链表的长度 [5/6/2008 By willing]
int CSelectFileList::GetItemCount()
{
	DWORD dwRe = WaitForSingleObject(hMutex,LIST_TIME_OUT);
	int nResult = 0;
	if (dwRe != WAIT_TIMEOUT)
	{
		nResult = selFileList.GetCount();
		ReleaseMutex(hMutex);
		return nResult;
	}
	return -1;
}
// 判断链表是否为空 [5/6/2008 By willing]
BOOL CSelectFileList::IsEmpty()
{
	DWORD dwRe = WaitForSingleObject(hMutex,LIST_TIME_OUT);
	BOOL bRe = TRUE;// 默认返链表为空 [5/6/2008 By willing]
	if (dwRe != WAIT_TIMEOUT)
	{
		bRe = selFileList.IsEmpty();
		ReleaseMutex(hMutex);
		return bRe;
	}
	return TRUE;
}
// 从链表的头部获取第一个元素 [5/6/2008 By willing]
BOOL CSelectFileList::GetHeadItem(CSelectFile &SelectFile)
{
	DWORD dwRe = WaitForSingleObject(hMutex,LIST_TIME_OUT);
	if (selFileList.IsEmpty())
	{
		return FALSE;
	}
	if (dwRe != WAIT_TIMEOUT)
	{
		SelectFile = selFileList.GetHead();
		selFileList.RemoveHead();
		ReleaseMutex(hMutex);
		return TRUE;
	}
	return FALSE;
}

⌨️ 快捷键说明

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