Programming C++Builder Insert Images in TCppWebbrowser on its design mode

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);  


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

Add comment

Security code

Programming - C++Builder