Using Twebbrowser to do controllable editor and mshtml

Source: Internet
Author: User
Tags close close

The first thing to understand is the Mshtml property method:

{IHTMLWindow2 property:}frames//returns the frame array in the window location//Return window of the Location object history//Return window to History               Object Navigator//returns the Navigator object of the window document//Returns the Document object of the window screen//returns to the Screens object self Returns the window//with the Self property Top//Returns the topmost window parent//returns to the Parents window opener/ /returns the window that created this window closed//window has been closed event//status of current events, useful external//execute external commands, such as favorites etc Clientinforma tion//Current browser information offscreenbuffering//whether to use double buffering, that is, before the object is displayed, do you want to draw the option//option-based interface in memory first? Image//Can create an image interface? item//Used to get the child frame? Length//Returns the number of frames in the window? Name//settings or returns the name of the window Defaultstatus//Sets or returns the default text status in the window status bar//settings or returns the text in the status bar of the window {IHTMLWindow2 method:}settimeout//In the specified Time (milliseconds) after calling a function or evaluating an expression setinterval//calling a function or evaluating an expression by a specified period of time (milliseconds) cleartimeout//Cancellation by SetTimeout settings Clearinterval//Cancel Set by SetInterval alert//Show Warning Box CoNfirm//Display a dialog box that can be confirmed or Canceled prompt//dialog box for user input ShowModalDialog//create and display a modal dialog box for an HTML document SHOWHELP//              Show Help file navigate//Set new URL, similar to Twebbrowser.navigateopen//Open a new browser window or find a named window close Close the browser window focus//Get focus blur//Remove focus moveto//Move window to specified position Moveby//Move window to relative position res              Izeto//Set window width and height resizeby//Set window relative width and height scrollto//Scroll to specified position Scrollby//scroll to relative position scroll Same as Scrolltoexecscript//execute script {IHTMLWindow2 event: Trigger when}onload//trigger OnUnload//exit after Mount completes             onbeforeunload//Trigger on exit, it will occur before onunload, if you want to use this onhelp//display Help when trigger onfocus//Get Focus trigger onblur Trigger when onerror//error is triggered when the focus is lost when onresize//change size is triggered when onscroll//scroll is triggered {IHTMLWindow3 method:}attac Hevent//Bind event DetachEvent//Cancel Event binding settimeout//Call function or evaluate expression after specified time (milliseconds)///By the specified time period (milliseconds)          Print with a function or calculation expression    Print showModelessDialog//Create a non-modal dialog box that displays HTML content {IHTMLWindow3 property:}screenleft//screentop//clipboarddata//Clipboard data {IH TMLWINDOW3 event:}onbeforeprint//Before printing Onafterprint//After printing {IHTMLWindow4 method:}createpopup//Create popup Menu {IHTMLWindow4 property:} FrameElement//Gets the frame object where the window is located
View Code

It will be a lot easier to figure out the relevant information above.

1, hope that only some of the content can be edited: note the use of "contenteditable=true":

<BODY><Pcontenteditable=true>Usegear (can only be edited here) </p><P>&nbsp;</P><P>&nbsp;</P><P>68767896897</P><P>&nbsp;</P><P>Yutyuty</P><P>&nbsp;</P></BODY>

2. Want to insert HTML text or other in the editable area at the cursor

(Webbrowser1.document as IHTMLDocument2). Selection.createrange as IHTMLTxtRange). pastehtml (' Hello usegear! ');

3. Processing of image files in HTML files
Because the result of the edit is an HTML file that needs to be like a file with a Word document, and not possibly a separate image file, the image file is converted to Base64 text in HTML

Uses encddecd;//d the unit, do not look for the =======================var mystringstream:tstringstream everywhere  ;  Mystream:tstream;===================stringstream: = Tstringstream.create ("); MyStream: = TFileStream.Create (' f:\ QQ picture 20170923175727.png ', fmopenread); Encddecd.encodestream (Mystream,mystringstream); Mmo1. Text: = '  ';(( Webbrowser1.document as IHTMLDocument2). Selection.createrange as IHTMLTxtRange). pastehtml (Mmo1. Text);

  

4, other editing functions, online a lot.

 Web viewing mode (webbrowser1.document as IHTMLDocument2). DesignMode: = ' on '; (Webbrowser1.document as IHTMLDocument2). ExecCommand (' EditMode ', false,1);///page edit mode (webbrowser1.document as    IHTMLDocument2). DesignMode: = ' off '; (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Browsemode ', false,1);        Select the Chinese text editor///Set Font//////name (webbrowser1.document as IHTMLDocument2). ExecCommand (' FontName ', False, ' Arial ');//////size (Webbrowser1.document as IHTMLDocument2). ExecCommand (' FontSize ', False, 7);//////The font size is from 1 to 7////style//////bold (webbrows Er1. Document as IHTMLDocument2). ExecCommand (' Bold ', False, 1),//////Italic (webbrowser1.document as IHTMLDocument2). execcom Mand (' Italic ', false, 1);/////underline (webbrowser1.document as IHTMLDocument2). ExecCommand (' underline ', false, 1);/////Delete    Except line (webbrowser1.document as IHTMLDocument2). ExecCommand (' Strikethrough ', False, 1);     Hyperlinks (webbrowser1.document as IHTMLDocument2). ExecCommand (' Createlink ', False, 1);///delete hyperlink(Webbrowser1.document as IHTMLDocument2). ExecCommand (' UnLink ', False, 1); Set///Set text foreground color (webbrowser1.document as IHTMLDocument2). ExecCommand (' ForeColor ', False, ' Red ');///Set Text background color ( Webbrowser1.document as IHTMLDocument2). ExecCommand (' BackColor ', False, ' Blue '); Set subscript (webbrowser1.document as Ihtmldocument2). ExecCommand (' subscript ', false,1);///Set superscript (webbrowser1.documen T as Ihtmldocument2). ExecCommand (' superscript ', false,1); Set alignment///Set left-aligned (webbrowser1.document as IHTMLDocument2). ExecCommand (' Justifyleft ', False, 0);///Set Alignment (WebB Rowser1. Document as IHTMLDocument2). ExecCommand (' Justifycenter ', False, 0);///Set right justification (webbrowser1.document as IHTMLDocument2) . ExecCommand (' Justifyright ', False, 0);///Set Justify (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Justifyfull '  , False, 0); Indent//Indent right (webbrowser1.document as Ihtmldocument2). ExecCommand (' Indent ', true,1);///Left indent (webbrowser1.docu ment as Ihtmldocument2). ExecCommand (' outdent ', true,1); Clear Format (webbrowser1.document as Ihtmldocument2). ExecCommand (' Removeformat ', true,0); Sequence view///digital format (webbrowser1.document as Ihtmldocument2). ExecCommand (' insertorderedlist ', true,0);///Dot View (Webbrow Ser1. Document as Ihtmldocument2). ExecCommand (' insertunorderedlist ', true,0);                          Insert Picture (Static) (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Insertimage ', True, '); (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Insertimage ', False, ' C:\1.png '); Insert the HTML component///The following string for the control's ID number///Straight line (webbrowser1.document as IHTMLDocument2). ExecCommand (' Inserthoriz Ontalrule ', True, ');////button (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Insertbutton ', Tru E, ');////check box checkbox (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Insertinputcheckbox ', True, ');//        /Radio Box Radio (webbrowser1.document as IHTMLDocument2). ExecCommand (' Insertinputradio ', True, ');///edit box         Edit(Webbrowser1.document as IHTMLDocument2). ExecCommand (' Insertinputtext ', True, ');////text box Memo (WebBrowser1. Document as IHTMLDocument2). ExecCommand (' Inserttextarea ', True, ');///Password box Pswedit (webbrowser1.document as IH TMLDocument2). ExecCommand (' Insertinputpassword ', True, ');///Group Framework GroupBox (Webbrowser1.document as Ihtmldocume NT2). ExecCommand (' Insertiframe ', True, ');/////List box ListBox (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Insertselectlistbox ', True, ');/////Combo box combobox (Webbrowser1.document as IHTMLDocument2). ExecCommand (' Inserts Electdropdown ', True, ');

2CCC has a tall man n years ago written browser editor, you can refer to Register_htmledit

Using Twebbrowser to do controllable editor and mshtml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.