cppwebbrowser

Sometimes you need to make the webpages editalbe in your programs. Microsoft have supply a component webbrowser to do this. In c++builder, you could use this component TCppWebbrowser easily.

The function are:

IHTMLDocument2::put_designMode(L"On");//Open the design mode(edit mode)  
IHTMLDocument2::put_designMode(L"Off");//Close the design mode 

For detail, see the below steps.

1. Create a new project in c++builder platform.

2. Drag a CppWebbrowser onto the form from the tab internet toolbar, renamed it to "web".

3. Double click the onDocumentComplete events, adding the following codes.

void __fastcall TForm1::webDocumentComplete(TObject *Sender,
      LPDISPATCH pDisp, Variant *URL)
{
    IHTMLDocument2* doc;    //This interface is defined in mshtml.h

    HRESULT hr;
    hr = web->Document->QueryInterface(IID_IHTMLDocument2,(void**)&doc);
    if(SUCCEEDED(hr))
    {
        doc->put_designMode(L"On");
        doc->Release();            //Release the object

    }
}
 

4. Put a botton on the form, adding the following codes in its onclick event

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    web->Navigate(L"http://codeback.net");

Now, run your program. Click the button1, do you find the page is editable?

Notice: you have to include this line in your file header, #include "mshtml.h".

If you are using Delphi, and want to make the TWebBrowser editable in Delphi, see this article Use the TWebBrowser as an html editor in delphi .