delphi编程 实现一功能解决办法
delphi编程 实现一功能
该问题的详细介绍在盒子里我写的很清楚了,有能力的高手,到以下地址查看。
http://bbs.2ccc.com/topic.asp?topicid=275297
该问题不管是用什么方法或控件,只要能实现就行!
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//生成html代码
private static string GetHtmlCode(string strSource)
{
string strOutput = "<html><head></head><body style=\"background-color:ButtonFace\">";
foreach (string strs in strSource.Split(new char[] { '[', ']' }))
{
string[] info = strs.Split('/');
if (info.Length == 2)
{
strOutput +=
string.Format("<a href=\"javascript:window.alert('{0}')\" title='{0}'>{1}</a>", info[1], info[0]);
}
else
{
strOutput += strs;
}
}
strOutput += "</body></html>";
return strOutput;
}
private void Form1_Load(object sender, EventArgs e)
{
//输入字符串
string strSource = "一台电脑是由多部分组成的,其中包括有[显示器/显示器是电脑的标准输出单元,可显示程序执行及操作的过程与实时性的输出结果],键盘,鼠标,和主机!" +
"其中主机包括有CPU,内存,[硬盘/简称HD,是个人计算机中最主要的储存设备即辅助内存],主板,电源等部件!";
//获取html
string strInfo = GetHtmlCode(strSource);
//设置浏览器控件滚动条
this.webBrowser1.ScrollBarsEnabled = false;
//设置浏览器显示文本
this.webBrowser1.DocumentText = strInfo;
}
}
}
------解决方案--------------------
http://community.****.net/IndexPage/SmartQuestion.aspx#bespecific
------解决方案--------------------
procedure TForm1.Button1Click(Sender: TObject);
var
iText:string;
begin
iText:='<html><body>一台电脑是由多部分组成的,其中包括有<a href="@LoadForm|显示器是电脑的标准输出单元,可显示程序执行及操作的过程与实时性的输出结果"><font color=red>显示器</font></a>,键盘,鼠标,和主机!'
+'其中主机包括有CPU,内存,<a href="@LoadForm|简称HD,是个人计算机中最主要的储存设备即辅助内存"><font color=blue><i>硬盘</i></font></a>,主板,电源等部件!</body></html>';
(WebBrowser1.Document as IHtmlDocument2).Body.innerHTML:= iText;
end;
上面iText的格式根据所提供的字符串来生成,这个比较简单就不用多说了,楼上也有相关的代码可以参考。
只是把链接地址改一下就可以了。
下面:
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
if POS('LoadForm',URL)>0 then
begin
//+===============================打开新窗体把URL付到新窗体的Memo中就可以了。
Cancel:= true;
end;
end;
------解决方案--------------------
文本转为html,文本转为html时候控制超级链接颜色之类的格式,然后用THTMLViewer控件打开html文件
------解决方案--------------------
>>3部分功能你没实现,也就是要用程序的窗口来显示关键字2
可以随便写个url把window.alert替换掉
然后再webbrowser的beforenavigate事件中截获url中的信息,弹一个新窗体出来
该问题的详细介绍在盒子里我写的很清楚了,有能力的高手,到以下地址查看。
http://bbs.2ccc.com/topic.asp?topicid=275297
该问题不管是用什么方法或控件,只要能实现就行!
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//生成html代码
private static string GetHtmlCode(string strSource)
{
string strOutput = "<html><head></head><body style=\"background-color:ButtonFace\">";
foreach (string strs in strSource.Split(new char[] { '[', ']' }))
{
string[] info = strs.Split('/');
if (info.Length == 2)
{
strOutput +=
string.Format("<a href=\"javascript:window.alert('{0}')\" title='{0}'>{1}</a>", info[1], info[0]);
}
else
{
strOutput += strs;
}
}
strOutput += "</body></html>";
return strOutput;
}
private void Form1_Load(object sender, EventArgs e)
{
//输入字符串
string strSource = "一台电脑是由多部分组成的,其中包括有[显示器/显示器是电脑的标准输出单元,可显示程序执行及操作的过程与实时性的输出结果],键盘,鼠标,和主机!" +
"其中主机包括有CPU,内存,[硬盘/简称HD,是个人计算机中最主要的储存设备即辅助内存],主板,电源等部件!";
//获取html
string strInfo = GetHtmlCode(strSource);
//设置浏览器控件滚动条
this.webBrowser1.ScrollBarsEnabled = false;
//设置浏览器显示文本
this.webBrowser1.DocumentText = strInfo;
}
}
}
------解决方案--------------------
http://community.****.net/IndexPage/SmartQuestion.aspx#bespecific
------解决方案--------------------
procedure TForm1.Button1Click(Sender: TObject);
var
iText:string;
begin
iText:='<html><body>一台电脑是由多部分组成的,其中包括有<a href="@LoadForm|显示器是电脑的标准输出单元,可显示程序执行及操作的过程与实时性的输出结果"><font color=red>显示器</font></a>,键盘,鼠标,和主机!'
+'其中主机包括有CPU,内存,<a href="@LoadForm|简称HD,是个人计算机中最主要的储存设备即辅助内存"><font color=blue><i>硬盘</i></font></a>,主板,电源等部件!</body></html>';
(WebBrowser1.Document as IHtmlDocument2).Body.innerHTML:= iText;
end;
上面iText的格式根据所提供的字符串来生成,这个比较简单就不用多说了,楼上也有相关的代码可以参考。
只是把链接地址改一下就可以了。
下面:
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
if POS('LoadForm',URL)>0 then
begin
//+===============================打开新窗体把URL付到新窗体的Memo中就可以了。
Cancel:= true;
end;
end;
------解决方案--------------------
文本转为html,文本转为html时候控制超级链接颜色之类的格式,然后用THTMLViewer控件打开html文件
------解决方案--------------------
>>3部分功能你没实现,也就是要用程序的窗口来显示关键字2
可以随便写个url把window.alert替换掉
然后再webbrowser的beforenavigate事件中截获url中的信息,弹一个新窗体出来