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

📄 infotextlibrary.cpp

📁 c++系统开发实例精粹内附的80例源代码 环境:windows2000,c++6.0
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
//       http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////

// InfoTextLibrary.cpp: implementation of the CInfoTextLibrary class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Oscar.h"
#include "InfoTextLibrary.h"

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

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

CInfoTextLibrary::CInfoTextLibrary()
{
	m_nNextMessage = -1;

	Init();
}

CInfoTextLibrary::~CInfoTextLibrary()
{

}

void CInfoTextLibrary::Init()
{
	m_cszaInfoText.RemoveAll();     // Clear out anything.

	// Add all info statements.
	CString cszNewInfo = _T("FileFury is a free program; give it to your friends!");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("This is a beta version; check for upgrades often.");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("If you find any problems, please report them to FileFury.com");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("Share your public files so your friends can"
		" find them!");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("To share a directory, right-click it and select \"Share...\"");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("Downloading is easy- just drag and drop!");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("Suggestions?  Submit them at FileFury.com");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("The FurySearch feature will search the Internet for you.");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("Add your friends so you can search their computers.");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("To add a friend, use \"Add...\" from the Friends menu.");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("Send a message to your friend!  Click the \"Message\" button.");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("You can easily reply to messages- just double-click them!");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("Want to know who's surfing your machine?  Use Network Monitor.");
	m_cszaInfoText.Add(cszNewInfo);
	cszNewInfo = _T("Want to watch your search?  Use Network Monitor.");
	m_cszaInfoText.Add(cszNewInfo);

	ScrambleItems();

	return;
}

CString CInfoTextLibrary::GetNextMessage()
{
	m_nNextMessage += 1;

	if(m_cszaInfoText.GetSize() == 0) return _T("");
	if(m_nNextMessage >= m_cszaInfoText.GetSize())
		m_nNextMessage = 0;

	return m_cszaInfoText.GetAt(m_nNextMessage);
}

void CInfoTextLibrary::ScrambleItems()
{
	CStringArray cszArray;

	// Make sure the results are different each time.
	srand( (unsigned)time( NULL ) );

	// Fill the new array with scrambled-order items.
	cszArray.SetSize(m_cszaInfoText.GetSize());
	for(int i = 0; i < m_cszaInfoText.GetSize(); i++)
	{
		// Insert the i'th item into a random position in the
		// buffer array.

		// Get a random position not yet taken.
		int r = -1;
		CString cszLastString;
		while(r < 0 || cszLastString.GetLength() > 0)
		{
			// Get a random number.
			r = rand();
			// Fix it to fit into the array.
			r %= m_cszaInfoText.GetSize();

			ASSERT(r < m_cszaInfoText.GetSize() &&
				r > -1);

			cszLastString = cszArray.GetAt(r);
		}

		// Insert the string into the random position.
		cszArray.SetAt(r, m_cszaInfoText.GetAt(i));
	}

	// Copy the buffer into the main array.
	for(i = 0; i < m_cszaInfoText.GetSize(); i++)
		m_cszaInfoText.SetAt(i, cszArray.GetAt(i));

	return;
}

⌨️ 快捷键说明

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