- How do I implement the UMC?
- Configuring the project
- Describing the windows
- Create the executable
- Functions specific to the management of UMC
- Using the UMC in an application
- Importing User Macro-Codes
UMC: Implementing and managing the "User Macro-Codes"
Regardless of the skill of the development team, the end user will always want to do something that has not been planned for.
To allow the advanced users to customize their applications, WinDev proposes the UMC mode: the end user has the ability to enter WLanguage code and "graft" it to an existing application.
This feature is not available by default: you have the ability to enable or disable this feature at any time.
Caution: The modification of an application by the end user may cause unexpected behavior of the application. This feature must be used with great care.
How do I implement the UMC?
To implement the UMC in a WinDev application, all you have to do is allow the input of User Macro-Codes:
- when describing the project,
- when creating the executable.
If the UMC was implemented by one of these two options, the input of User Macro-Codes will be allowed by default in all the windows of your application.
For each window of your application, you can specify whether the input of User Macro-Codes is allowed or not in this window.
When using the application, the User Macro-Codes are saved in .MCU files. These User Macro-Codes can be imported into the project in order to modify the application according to the requirements of the end user. See Importing User Macro-Codes into the project for more details.
Note: where is the User Macro-Code stored?
When the user enters a new User Macro-Code, this information is stored in a .MCU file. Until version 160047, this .MCU file was found in the executable directory. From now on, this file is saved in the data directory of the user (returned by 文件用户数据目录
). Any modification of an existing User Macro-Code triggers the move of the corresponding MCU file.
For a network application, if the executable is installed in a shared network directory, the .MCU file will be saved in the "MyDocuments\Application Data\<Project name> directory.
Configuring the projectWhen describing the project, the UMC can be configured for the entire project ("Project .. Project description").
This configuration is performed via the "User Macro-Code" button found in the "Advanced" tab of the project description.When describing the project, the UMC can be configured for the entire project:
- On the "项目" pane, in the "项目" group, click "描述".
- In the "Advanced" tab, click the "User Macro-Code" button.
In this screen:
- You can allow (or not) the input of UMC on the project windows.
- If the input of UMC is allowed on the project windows, you can:
- Restricting the input of UMC to the users who know the specified password. Therefore, some users will not be allowed to modify the application.
- Allow the use of HyperFileSQL read commands. If this option is checked, the end user will be able to read and browse the records found in the HyperFileSQL data files of the application. In any case, the end user will not be able to modify or create new records or new data files.Allow the use of HFSQL read commands. If this option is checked, the end user will be able to read and browse the records found in the HFSQL data files of the application. In any case, the end user will not be able to modify or create new records or new data files.
- Accept the suggestions made by the users. If this option is checked, you have the ability to enter the email address to which the suggestions of the users (which means the macro-codes written by the users) will be sent.
Describing the windows
When describing each window, you can forbid the input of User Macro-Codes for this window.
To do so, check "Forbid the use of UMC" in the "Details" tab of the window description.
Create the executable
When creating the executable, you also have the ability to enable (or not) the input of User Macro-Codes. The information entered is identical to the information entered when configuring the project. This information will be automatically included in the project description.
- To move the UMC button, create a new button, associated with the preset action "Open the edit window of User Macro-Code". In this case, the default button will not be displayed anymore. The new button can be positioned anywhere in the window.
- To make a control invisible in the configuration window of UMC (a hidden control for example), its name must start with "__WXMUC_". The name of the control will not be proposed to the users.
Functions specific to the management of UMC
Several WLanguage functions are used to define the input of User Macro-Codes in an application
|模式为用户宏代码||Indicates whether the code is run from a code written in a user macro-code. For example, in the code of a procedure, enables you to find out whether the procedure was run from a User Macro-Code or not.|
|用户宏代码启用||Allows you to find out and modify the management of UMC for the current project or component.|
|用户宏代码打开||Allows you to open the window allowing the user to enter a new "User Macro-Code".|
Using the UMC in an application
The input of new User Macro-Codes in an application is child's play. If the window allows the input of a User Macro-Code, the icon
is displayed beside the minimize button of the window. When this icon is clicked, a wizard is displayed, allowing the end user to create and use his own User Macro-Codes.
See Using the UMC for more details.
Importing User Macro-Codes
To import User Macro-Codes into your project:
- Select "File .. Import .. User Macro-Codes".On the "项目" pane, in the "项目" group, expand "导入" and select "User Macro-Codes".
- Select the .MCU file corresponding to the Macro-Code to import. Validate.
- Select the User Macro-Codes to import.
The buttonallows you to see the modifications made by the user in relation to the existing code.
- Validate. The import is automatically performed. Comments are used to view the imported code section.