📄 htmlgen.pas
字号:
unit htmlGen;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,shellapi;
procedure apiexec(action:string;flag:integer);
type
ThtmlView = class
// filename:string;
constructor create;
Destructor destory;
procedure writeHeader(Title:string);
procedure addQues(id,userfrom,detail,datetime:string);
procedure add(id,userfrom,detail,datetime:string);
procedure addinfo(title,room,points:string);
procedure writeend;
function GetContent:string;
function TransStr(htmlstr:string):string;
private
content:Tstringlist;
end;
function getCurPath:string;
implementation
procedure apiexec(action: string; flag: integer);
begin
shellexecute(application.Handle,pchar('open'),pchar(action),pchar(''),pchar(ExtractFilePath(paramstr(0))),flag)
end;
{ ThtmlView }
procedure ThtmlView.add(id, userfrom, detail,datetime: string);
begin
content.Add('<TABLE BORDER=0 WIDTH="100%" cellspacing="1" cellpadding="5" >');
content.Add('<TR bgcolor="#D6D3CE" >');
content.Add('<TD width="40%" bgcolor="#CCE6FF"> <font color="#000000"><B>来自 :</B>' + userfrom +'</font></TD>');
content.Add('<TD bgcolor="#CCE6FF"> <font color="#000000"><B>时间 :</B>' + datetime +'</font></TD>');
content.Add('</TR>');
content.Add('<TR bgcolor="#F7F7F7">');
content.Add('<TD colspan="2" WIDTH="100%">');
content.Add('<FONT COLOR="#000000">' + TransStr(detail));
content.Add('</FONT>');
content.Add('</TD></TR></TABLE>');
content.Add('<BR><A NAME=' + id + '></A>');
content.Add('');
end;
procedure ThtmlView.addinfo(title, room ,points: string);
begin
content.Add('<p class="bigfont"><img src="'+ getCurPath +'\doc.jpg" width="48" height="48" align="absmiddle"><B>问题的标题是: </B>' + title + ' (' + points +'分 )</p>');
// content.Add('<BR><B>问题的分类是:' + room + '</B>');
end;
procedure ThtmlView.addQues(id, userfrom, detail, datetime: string);
begin
content.Add('<TABLE BORDER=0 WIDTH="100%" cellspacing="1" cellpadding="5" >');
content.Add('<TR bgcolor="#D6D3CE" >');
content.Add('<TD width="40%" bgcolor="#FFDFDF"> <font color="#000000"><B>来自 :</B>' + userfrom +'</font></TD>');
content.Add('<TD bgcolor="#FFDFDF"> <font color="#000000"><B>时间 :</B>' + datetime +'</font></TD>');
content.Add('</TR>');
content.Add('<TR bgcolor="#FFFFEE">');
content.Add('<TD colspan="2" WIDTH="100%">');
content.Add('<FONT COLOR="#000000">' + TransStr(detail));
content.Add('</FONT>');
content.Add('</TD></TR></TABLE>');
content.Add('<BR><A NAME=' + id + '></A>');
end;
constructor ThtmlView.create;
begin
content:=tstringlist.Create;
end;
destructor ThtmlView.destory;
begin
content.Free;
end;
function getCurPath: string;
begin
Result := ExtractFilePath(Application.ExeName);
end;
function ThtmlView.GetContent: string;
begin
Result := content.Text;
end;
function ThtmlView.TransStr(htmlstr: string): string;
begin
Result := StringReplace(htmlstr,#13#10,'<BR>'+#13#10,[rfReplaceAll]);
end;
procedure ThtmlView.writeend;
begin
content.Add('</BODY>');
content.Add('</HTML>');
end;
procedure ThtmlView.writeHeader(Title:string);
begin
content.Add('<HTML>');
content.Add('<HEAD>');
content.Add(' <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">');
content.Add(' <TITLE>' + title + '</TITLE>');
content.Add('<link rel="stylesheet" href="'+ getCurPath +'style.css">');
content.Add('</HEAD>');
content.Add('<BODY BACKGROUND="'+ getCurPath +'bg.gif">');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -