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

📄 mainfrm.cpp

📁 API经典入门
💻 CPP
字号:
// mainfrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "misc.h"

#include "mainfrm.h"
#include "compdlg.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_CSTRING_CONSTRUCT, OnCstringConstruct)
	ON_COMMAND(ID_CSTRING_COMPARE, OnCstringCompare)
	ON_COMMAND(ID_CSTRING_EXTRACTION, OnCstringExtraction)
	ON_COMMAND(ID_CSTRING_CONVERSION, OnCstringConversion)
	ON_COMMAND(ID_CSTRING_FIND, OnCstringFind)
	ON_COMMAND(ID_CSTRING_BUFFERING, OnCstringBuffering)
	ON_COMMAND(ID_CEXCEPTION_TEST, OnCexceptionTest)
	ON_COMMAND(ID_CTIME_TEST, OnCtimeTest)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// arrays of IDs used to initialize control bars

// toolbar buttons - IDs are command buttons
static UINT BASED_CODE buttons[] =
{
	// same order as in the bitmap 'toolbar.bmp'
	ID_FILE_NEW,
	ID_FILE_OPEN,
	ID_FILE_SAVE,
		ID_SEPARATOR,
	ID_EDIT_CUT,
	ID_EDIT_COPY,
	ID_EDIT_PASTE,
		ID_SEPARATOR,
	ID_FILE_PRINT,
	ID_APP_ABOUT,
};

static UINT BASED_CODE indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_wndToolBar.Create(this) ||
		!m_wndToolBar.LoadBitmap(IDR_MAINFRAME) ||
		!m_wndToolBar.SetButtons(buttons,
		  sizeof(buttons)/sizeof(UINT)))
	{
		TRACE("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE("Failed to create status bar\n");
		return -1;      // fail to create
	}

	return 0;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG


/////////////////////////////////////////////////////////////////////////////
// CMainFrame operations

CString CMainFrame::Strip (const char* pszS, const char* pszSet)
{
	CString S = pszS;
	CString Result;
	
	while (!S.IsEmpty())
	{
		CString temp = S.SpanExcluding(pszSet);
		if (temp == "")
			 // strip off the leading char
			 S = S.Right(S.GetLength() - 1);
		else
			// otherwise remove temp from S
			S = S.Right(S.GetLength() - temp.GetLength());
			
		Result += temp;
	}
	
	return Result;
}

void CMainFrame::AutoCorrect (CString& S)
{
	CString str1 = "teh";
	CString str2 = "the";
	// better yet, make this a list of misspelled words
	// and their corrections.
	
	int i; // index holding the position of str1 in S
	
	// find all the occurrences of str1 in S
	while( (i = S.Find(str1)) >= 0)
	{
		// replace str1 with str2 in the S string
		S = S.Left(i) + str2 + 
			S.Right(S.GetLength() - str1.GetLength() - i);
	}
	
}

BOOL CMainFrame::IsEquivalent(const char* pszPureStr, const char* pszWildStr)
{
	CString Pure = pszPureStr;
	CString Wild = pszWildStr;

	int i = Wild.FindOneOf("*?");

	if (i < 0)  // wildcard NOT found
		return Pure == Wild;
	else if (Wild.GetAt(i) == '*')
	{
		int len = Wild.GetLength();
		return ( (Wild.Left(i) == Pure.Left(i)) &&
			 (Wild.Right(len - i - 1) == Pure.Right(len - i - 1)) );
	}
	else // wildcard found was 

⌨️ 快捷键说明

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