Programming C++Builder Insert Images in TCppWebbrowser on its design mode
Notice: Undefined variable: relatedArticlesCount in /home/wwwroot/codeback.net/plugins/content/tags.php on line 149

Webbrowser supports many of the surface to control the browser. This is a sample to show how to insert an image into the current position in the webbrowser component. 

Make a new project, then put a cppwebbrowser and a button to the form.  double click the button, adding the following codes.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    IHTMLDocument2*   doc;  
    HRESULT   hr   =   CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,(void**)&doc); 

    if(hr   ==   S_OK)  
    {  
          VARIANT   var;  
          VARIANT_BOOL         receive;  
          doc->execCommand(L"InsertImage",t rue,v ar, &receive);  
          doc->Release();  
    }  

}

Run your project, enjoy the program! Of course, don't forget to add "#include  " in your header. 

To make the cppwebbrowser editable, see the article here http://codeback.net/how-to-make-the-tcppwebbrowser-editable-in-c-builder


Add comment


Security code
Refresh

Programming - C++Builder