DuiVision development tutorial (4)-use zip resources, duivisionzip
Load resources from ZIP files
DuiVision allows you to place all images and XML resource files in a zip file. If you use a zip file, the file name of the compressed file to be used must be initialized in the main program code.
If a zip resource file is used, the location of the resource. xml file is stored in the xml subdirectory of the zip file by default. It is recommended that zip files be compressed according to subdirectories such as xml and skins. See the following compressed file example:
When a zip resource file is available, the resource file loading is not necessarily the content of the loaded zip file. The loading priority is as follows:
1) if only zip files are compressed and there are no non-compressed xml and skins directories, only the content in the zip file will be loaded;
2) If both the zip compressed file and the non-compressed xml and skins directories exist, the files in the non-compressed xml and skins directories are preferentially loaded, if the corresponding file does not exist, go to the zip file to find whether the file exists and load it.
This definition makes it easy to replace part of the compressed file with a non-compressed file, and facilitate debugging and release of the project. In the debugging phase, you can directly modify the files in the non-compressed directory, you do not need to create a compressed package again after each modification.
Note: zip files only support files of the xml, png, and bmp types. Other files cannot be loaded. If there are other types of files, do not place them in the zip file, it should be loaded separately in an external directory.
Use the ZIP compressed resource file as the embedded resource of the EXE
DuiVision allows you to use the resource zip file as an embedded resource of the EXE. By compiling the resource file into the exe, you can generate an exe file that is independent of the task resource file and can run independently.
How to create embedded ZIP resources:
1. compress the subdirectories and files used by all resources in the bin directory into ZIP files (refer to the directory structure during compression in the previous section );
2. Add the compressed file as a resource to the project resource. Enter "UI" for the resource type when adding the file ";
Add resources to the resources of the VC project and select import:
In the import dialog box, select the resource zip file and enter the UI in the pop-up Custom Resource Type dialog box. This type is required, duiVision limits that the loaded embedded interface package resources must be of the "UI" type.
3. The strResourceFile parameter uses the res: resid format when calling the DuiSystem constructor. The resid is the ID of the added resource, and the resource ID can be found in the resource. h file;
4. In this way, the compiled EXE file can use the embedded interface resource file (if the directory where the EXE is located contains resource-related directories and files, the external file will be preferentially used ).
DuiVision open source code (github): https://github.com/blueantst/DuiVision
Ant financial studio home page: http://www.blueantstudio.net
DuiVision QQ group: 325880743
Public Account: blueantstudio or search for blue ant Studio