Analysis of the working principle of the WB editor plug-in [yysun]

Source: Internet
Author: User

WB editor can enrich its functions through plug-ins. For example, a spelling check plug-in, a quick typographical plug-in, and a highlighted syntax plug-in have been released.

The WB editor plug-in is a plug-in software module, which is compiled into a DLL. As long as you put it in the running directory of WB Editor, WB editor can automatically identify it. Deleting the plug-in DLL does not affect the basic functions of WB editor. A plug-in can have multiple commands, and each command can be used to implement a function. For example, a check plug-in has multiple commands to check English, French, German, and Spanish ....

To understand the working principle of the WB editor plug-in, first look at what is the WB editor plug-in.

The plug-in is a class that implements the iwbeditorplugin interface.

Public interface iwbeditorplugin
{
String getpluginname ();
String [] getcommands (string parentcommand );
Int querystatus (string name );
Void executecommand (string name );
}

When WB editor is started, it automatically scans all the DLL files under the program running directory and finds the classes that implement the iwbeditorplugin interface. After finding the plug-in, load the plug-in class dynamically, call its getpluginname method to query the plug-in name, and display the name under the plugin menu. Continue to use getcommands to query the plug-in command names and display them under the plug-in name menu. This enables multiple commands of a plug-in. Getcommands can return NULL, indicating that there is no command, and the plug-in name becomes a unique command.

If the user clicks the plug-in menu, WB editor calls executecommand to execute the command selected by the user. At this time, the control of the program running is handed over to the plug-in.

How does the plug-in control WB editor? This requires the wbeditorservice class. WB editor has initialized wbeditorservice before it starts to run. The plug-in can

-Use wbeditorservice. geteditorcontent to get the content in the editor.
-Use wbeditorservice. seteditorcontent to set the new editing content.
-Use wbeditorservice. getselection to obtain the selected content in the editor.
-Use wbeditorservice. inserttext to insert content to the editor.
-There are also advanced functions for text replacement, obtaining com ihtmlelement, ihtmldocument, and RSS item xmldocument.

WB editor plug-in interface standards and references: http://www.wbeditor.com/content/view/34/44

The WB editor plug-in can be implemented using C #, VB. NET or Delphi 8, because it is a. Net family.
The practice is:
1. Create a class library, add reference iwbeditorplugin. dll
2. Create a class of iwbeditorplugin interface and plug-in functions.
3. After compilation, copy the obtained DLL to the WB editor running directory. Run WB editor again and you will see a new plug-in under the Plugins menu.

If you are interested, please try it.

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.