Delphi IHTMLDocument2和Internet Explorer 11在Windows 7上的更改

Delphi IHTMLDocument2和Internet Explorer 11在Windows 7上的更改,delphi,webbrowser-control,c++builder,twebbrowser,Delphi,Webbrowser Control,C++builder,Twebbrowser,我使用TWebBrowser在我的应用程序中使用HTML编辑器,当然这取决于安装的Internet Explorer版本。在Windows7上安装了全新的InternetExplorer11之后,我注意到我的编辑器已经改变了。段落似乎不再具有相同的HTML代码 按下enter键之前生成的HTML: <P>&nbsp;</P> 现在生成的HTML: <P><BR></P> 这在我的编辑器中给了我额外的一行,看起来不太正

我使用TWebBrowser在我的应用程序中使用HTML编辑器,当然这取决于安装的Internet Explorer版本。在Windows7上安装了全新的InternetExplorer11之后,我注意到我的编辑器已经改变了。段落似乎不再具有相同的HTML代码

按下enter键之前生成的HTML:

<P>&nbsp;</P>

现在生成的HTML:

<P><BR></P>


这在我的编辑器中给了我额外的一行,看起来不太正确<代码>

本身有一个新行,


在这里是完全无用的

在编辑模式下,有没有办法告诉MSHTML/TWebBrowser控件在按下enter键时要使用哪个标记?例如,我看到一些MS程序生成:

<div><font></font></div>

按enter键进入新行时

还有(如果相关的话)-当我使用命令设置例如字体大小(而不是过时的size=1到size=7来使用类似“font-size:10px”的CSS)时,是否有一种方法来控制将使用哪些标记


代码在Delphi和C++ Builder中欢迎使用.< /P> < P>使用<强> bCBHTML > 首先将html.cpp添加到项目中,并包括“html.h”:

在全局范围内定义文档变量:

THTMLDocument document;

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    WebBrowser1->Navigate("about:<div contenteditable=true>Type here</div>"); // example editable region
}

void __fastcall TForm1::WebBrowser1DocumentComplete(TObject *ASender, const IDispatch *pDisp,
          const OleVariant &URL)
{
    document.documentFromVariant(WebBrowser1->Document);
    document.onkeydown = &onkeydown;
}

void TForm1::onkeydown()
{
    EventObj event = document.parentWindow.event;
    if(event.keyCode == VK_RETURN)
    {
        document.selection.createRange().pasteHTML("<P>&nbsp;</P>"); // You can put every html you like per every key code
        event.returnValue = false; // blocks default html which will be generated
    }
}
thtml文档文件;
__fastcall TForm1::TForm1(TComponent*Owner)
:t表格(所有者)
{
WebBrowser1->导航(“关于:在此处键入”);//示例可编辑区域
}
void u fastcall TForm1::WebBrowser1文档完成(TObject*ASender、const IDispatch*pDisp、,
常量(变量和URL)
{
document.documentFromVariant(WebBrowser1->document);
document.onkeydown=&onkeydown;
}
void TForm1::onkeydown()
{
EventObj事件=document.parentWindow.event;
if(event.keyCode==VK_RETURN)
{
document.selection.createRange()
event.returnValue=false;//阻止将生成的默认html
}
}
您可以从下载这个伟大的包装(bcbhtml)

THTMLDocument document;

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    WebBrowser1->Navigate("about:<div contenteditable=true>Type here</div>"); // example editable region
}

void __fastcall TForm1::WebBrowser1DocumentComplete(TObject *ASender, const IDispatch *pDisp,
          const OleVariant &URL)
{
    document.documentFromVariant(WebBrowser1->Document);
    document.onkeydown = &onkeydown;
}

void TForm1::onkeydown()
{
    EventObj event = document.parentWindow.event;
    if(event.keyCode == VK_RETURN)
    {
        document.selection.createRange().pasteHTML("<P>&nbsp;</P>"); // You can put every html you like per every key code
        event.returnValue = false; // blocks default html which will be generated
    }
}