- How to implement the UMC?
- Project configuration
- Describing windows
- Creating 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 to 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 different 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.
Remark: 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 fDataDirUser
). Any modification of an existing User Macro-Code triggers the move of the corresponding UMC 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.
When describing the project, the UMC can be configured for the entire project:
- On the "Project" pane, in the "Project" group, click "Description".
- 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:
- Restrict 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 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.
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.
Creating 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
|InUMCMode||Indicates whether the code is run from a code written in a user macro-code. For example, in the code of a procedure, allows you to find out whether the procedure was run from a User Macro-Code or not.|
|UMCActive||Used to find out and modify the management of UMC for the current project or component.|
|UMCOpen||Used 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 you to enter a User Macro-Code, the
icon is displayed beside the minimize icon 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.
Importing User Macro-Codes
To import User Macro-Codes into your project:
- On the "Project" pane, in the "Project" group, expand "Import" 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 button allows you to see the modifications performed by the user in relation to the existing code.
- Validate. The import is automatically performed. Comments are used to view the imported code section.
Click [Add] to post a comment