makehtml.cpp

来自「用Visual C++编写的查看磁盘信息的工具」· C++ 代码 · 共 80 行

CPP
80
字号
#include "..\stdafx.h"
#include <fstream.h>
#include <iostream.h>
#include "makehtml.h"

ofstream of;

bool CreateHTML(LPCTSTR lpscFileName, LPCTSTR lpscTitle)
{
	of.open(lpscFileName, ios::out);

	of	<<"<html>\n\n"
		<<"<head>\n"
		<<"\t<title>"<<lpscTitle<<"</title>\n"
		<<"</head>\n\n"
		<<"<body>\n\n";

	return true;
}

bool FinishHTML()
{
	of	<<"\n</body>\n"
		<<"</html>\n";

	of.close();

	return true;
}

void AddHTMLLine(LPCTSTR lpscLine, int nIndent)
{
	for (int i=0; i<nIndent; i++)
		of << "\t";
	of << lpscLine << "\n";
}

void InsertHTMLHeader(LPCTSTR lpscData)
{
	of <<"<h1>"<<lpscData<<"</h1>\n";
}

CString CreateHTMLImageString(LPCTSTR lpscData)
{
	CString str("<img src=\"");
	str += lpscData;
	str +="\">";

	return str;
}

void InsertHTMLHLine()
{
	of << "\n<hr>\n\n";
}

void CreateHTMLTable(LPCTSTR lpscData)
{
	of << "<table " << lpscData << ">\n";
}

void FinishHTMLTable()
{
	of << "</table>\n";
}

void CreateHTMLRow()
{
	of << "\t<tr>\n";
}

void FinishHTMLRow()
{
	of << "\t</tr>\n";
}

void InsertHTMLCell(LPCTSTR lpscParam, LPCTSTR lpscData)
{
	of << "\t\t<td " << lpscParam << ">" << lpscData << "</td>\n";
}

⌨️ 快捷键说明

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