我需要一个基本的WYSIWYG HTML编辑器组件,用于C++ Builder 5,让用户创建一些简单的文本,然后我将把它们粘贴到现有的HTML页面模板中。只需要简单支持创建链接、添加图片以及使用标题/加粗/斜体等功能。
我需要一个基本的WYSIWYG HTML编辑器组件,用于C++ Builder 5,让用户创建一些简单的文本,然后我将把它们粘贴到现有的HTML页面模板中。只需要简单支持创建链接、添加图片以及使用标题/加粗/斜体等功能。
// Delphi code..
(WebBrowser1.Document as IHTMLDocument2).designMode := 'on';
(WebBrowser.Document as IHTMLDocument2).body.innerHTML;
提供一套免费的EmbeddedWebBrowser
组件,其中包括一个编辑设计器组件,您可以将其链接到EmbeddedBrowser
窗口以控制设计模式并进行编辑控制,保存文件、插入链接、图像等等...
看起来运行良好!
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "mshtml.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "SHDocVw_OCX"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnNavigateAndEditClick(TObject *Sender)
{
wb->Navigate((WideString)"www.google.com");
while (wb->Busy)
Application->ProcessMessages();
if (wb->Document)
{
IHTMLDocument2 *html;
wb->Document->QueryInterface<IHTMLDocument2>(&html);
html->put_designMode(L"On");
html->Release();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnInsertImageClick(TObject *Sender)
{
if (wb->Document)
{
IHTMLDocument2 *html;
wb->Document->QueryInterface<IHTMLDocument2>(&html);
VARIANT var;
VARIANT_BOOL receive;
html->execCommand(L"InsertImage",true,var, &receive);
html->Release();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnGetHtmlClick(TObject *Sender)
{
if (wb->Document)
{
IHTMLDocument2 *html;
wb->Document->QueryInterface<IHTMLDocument2>(&html);
IHTMLElement *pElement;
html->get_body(&pElement);
pElement->get_parentElement(&pElement);
wchar_t *tmp;
pElement->get_outerHTML(&tmp);
Memo1->Lines->Text = tmp;
pElement->Release();
html->Release();
}
}
//---------------------------------------------------------------------------
Embarcadero\RadPHP\3.0\plugins\
文件夹。您会发现uHTMLEdit.pas
和uHTMLEdit.dfm
。这是一个单窗体HTML编辑器,除了标准VCL之外没有其他依赖项。 - Wouter van Nifterick