one. About Easy Language DLL
Starting from Yi Language version 3.6, it has been able to support the development of DLL dynamic link library. The compiled DLL is a standard DLL, and the calling method of standard DLLs generated by other programming languages is the same. DLLs written in Easy Language only need to be released with the application when compiling exe non-standalone, while DLL files are not required to be released with the application when compiling exe independently.
two. Create a new Easy Language DLL program
Create a new Easy Language program, and then select the "windows dynamic link library" icon, Easy Language will be automatically created
Out the code area (assembly) for writing the morphological connection library
After creation, you can write a DLL program in the code area.
three. How to generate a dynamic connection library (DLL)
The DLL writing method in Yi Language is similar to the writing method of Yi module, and both require an external public interface. Below, we will see how to write and call DLLs in Easy Language by writing a "self-created information box".
The public interface when writing a DLL can only be generated by the following methods: create a new subroutine, and then select "public". The subroutine selected "public" in any assembly in the DLL is used as an external interface:
Change the subprogram name to call it "Homemade Information Box", and then create two parameters "Title" and "Content", both of which are defined as integer types:
Note: Currently, the parameters in the DLL interface function can only be one of the following 9 types:
Byte type, short integer type, integer type, long integer type, decimal type, double precision decimal type, logic type, date time type, subroutine pointer type
After defining the DLL parameters, we can create a new form as an information box window, draw a button and a label on the new form. In order to allow the user to close the window after pressing the OK button, we can double-click the OK button to create a trigger event for the button to be clicked, and write the code:
Then return to the code section of Assembly 1 just now and start writing the code.
Since both parameters are defined as integer types, and the title and content passed during the call must be text-type, how to obtain the contents? Don't worry, this issue was considered in Yi Language version 3.6, so 3 new commands were added: "Pointer to Text", "Pointer to Byte Set", and "Write to Memory".
When the user passes text type or byte set type, Easy Language will automatically convert it into a pointer. We can use "Pointer to Text" or "Pointer to Byte Set" to return the original text. As shown in the figure below:
At this point, all the work of "Homemade Information Box DLL" has been completed. Finally, you can select the menu "Program" → "Compile" to compile it into DLL. As shown in the figure below:
You can also use the shortcut key "F7" to compile the DLL you just wrote. We name the compiled DLL name as "Homemade Information Box", as shown in the figure below:
Through the above, the program of writing DLLs in Easy Language is basically completed.
Four. How to use DLL
DLLs written in Easy Language can be called in Easy Language itself, and similarly, they can be called in other programming languages, such as (VB, VC, Delphi, etc.)
The call method in Yi Language is shown in the figure below:
Note: When defining, both parameters are defined as text types
Finally, please draw a button on the form, double-click the button, write the code and call this DLL. After pressing the button, you will see the effect!
Notes:
1: The corresponding command name of the Dll when calling DLL must be exactly the same as the interface name.
2: The parameters of the interface function must be the basic data type and cannot be byte set or text type.
3: In Yi Language version 3.6, three new commands "Pointer to Text", "Pointer to Byte Set", and "Write to Memory". The best use of these 3 commands is to use the Yi Language callback subroutine and Yi Language DLL to expose the subroutine to obtain external data. For the method of using text parameters in Dll, please refer to the "Pinyin of Chinese Characters.rar" program
4: If DLLs written in Easy Language are to be used in other programming languages, they must be accompanied by the corresponding Easy Language Support Library.
1. How to call type library in Easy Language
Q: What's type library?
A: A type library is a collection of descriptive information that involves the class of the component, interface and methods on the interface, and the parameter types of these methods. The type library is accessed through the ITYPELIB interface, and it can easily solve problems such as user interface, making program development easier.
Now in "Easy Language", type libraries can also be used, so how to call type libraries?
First run the "Easy Language" and select "Tools" → "Encapsulation Type Library and OCX Components" menu
A window to register OCX and type library will appear
We drag the scroll bar down to see a type library classification. Before this classification is the OCX component in our system. We are already very familiar with this, so we will not explain it here. After the type library classification, there are type libraries in our system. We can choose the registration we need to use.
We can select the type library we need and then select "Next"
Later we will see a window similar to the OCX registration we have used. Here we can do some Chinese operations on this type of library.
After completing the Chineseization work we need, we can click the "Save" button to save our previous operation
After clicking to save, there will be a prompt message to save the type library we registered in the "Easy Language" directory.
After we select "Yes", we will prompt that the installation will be successful
At this time, we run "Yi Language" again, and in the support library, we will see the type library we just registered.
At this point, we have completed the work of registering the type library into "Easy Language". Let's learn how to use these type library in "Easy Language".
First we expand the data type
We will see that there are many types below, and there are many commands below these types. We can regard them as defined custom data. Each type is a type name of the custom data type, and each command below is a member.
So how do we use them?
First create a variable, whose type is the name of these items. We may not find these in the type selection. We can click this item to expand all types and you will find what we need.
Just select the type we need
The specific usage method is the same as using a custom data type. Just use the commands in the selection type directly. If you can't understand it yet, think about how to use the font? Define "Font" as a font type, and use the "Font. Bold = True" method.
Let's look back and pull the scrollbar down, and we'll see some events
The arrow shows the events included in the Office type library. How to use these events
We will find that there are some additional controls in the control box. These controls are the trigger events of the type library we registered just now. When we need to use it, we can drag and drop it on the form as other components.
This is what we will find that there is an extra control in the property, and we just select the trigger event of the control.
His use is the same as other trigger events
At this point, we have already understood how to use type libraries in "Easy Language". Isn't it very simple? In fact, the use of type libraries is no different from other commands. Don’t feel how profound it is. As long as we have sound information, we can use them well to write good software for us.
2. How to use type library in Easy Language
How to use the type library in Easy Language, let’s use a small routine to illustrate below, first open “Easy Language”
Select "Tools" → "Encapsulation Type Library and OCX Components" to register the word type library.
Then the word type library will appear in the support library table on the left.
Then we draw two buttons in the form for us to use. As for the com control we draw next to us, let's wait.
Now we start writing the code. If we operate word according to the method of the com object, we must first create a word object and connect "". In fact, this is also calling the "Application" object in the "word" object. But now we don't need to do this. Through the type library, we can directly operate "Application" first, we create an assembly variable with the type "Application", so that we can directly operate the commands in "Application"
Enter in the "_button 1_clicked" event
The purpose of these two lines of code is to first set the visual attribute of word to "true", and then change the title of word to "Easy Language Word", run it to see if the effect has changed?
In the past, we used the com object to operate word, which could end word through the "quit" command provided by the word object, but there was no corresponding triggering event. We can only use it and cannot handle other things in these events. Now we can do it. The com control we saw above can play this role. We select this control in the component box on the right to draw it on the form.
This is all triggering events of the "Application" object in the word object. We select "Application Event 1" and select "quit" event in the event combo box.
A "_Application Event 1_Quit" subroutine will be generated in the code area. We will enter the following code below this subroutine.
This is just a trigger event for the "Application" object. How can we trigger it? Enter the following code in the "_button 2_clicked" subroutine
Now we run the code, first click button 1 to create, then click button 2 to close word, you will find that the "_Application Event 1_Quit" event has not been triggered, and the information box has not popped up, because although we called the "_Application Event 1_Quit" event, we did not hook the "_Application Event 1_Quit" event and "Application" event. We must hook this event with "Application" in "__Start Window_Create Complete", otherwise this event will not be triggered.
In this way, when we run Word, click button 2 to end, the information box will appear.