在C#里相实现类型QQ聊天的那种窗体,
一般是用webBrowser来实现的
我写了点简短代码以做参考:
注:要添加个引用 Microsoft.mshtml
窗体中:加入webBrowser,和两个Button
代码:加引用 using mshtml;
private void Form1_Load(object sender, EventArgs e)
{
NewShow();
}
private void NewShow()
{
StringBuilder html = new StringBuilder();
html.Append("<html><head></head><body><a href='http://www.facc.com.cn'>测试<img src='http://www.csdn.net/Images/logo_csdn.gif'></img></a></body></html>");
webBrowser1.DocumentText = html.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
doc.designMode = "On";
NewShow();
}
private void button2_Click(object sender, EventArgs e)
{
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
doc.designMode = "Off";
MessageBox.Show(webBrowser1.DocumentText);
}