Write class Windows menu in C

Source: Internet
Author: User

In the development of the program, the interface, openness is two very important aspects, at present, the UNIX system running the interface of the program is mostly rigid, and in the expansion of the function is not very convenient. So, can you design a program like windows that can adjust the interface and expand the function conveniently according to user's requirements? The answer is yes. Through practice, the author designed a menu program, so that users in the menu is not satisfied with the explicit style, simply through the menu parameter file operation can be completed on the menu location, width, length, whether there is a border and so on to adjust, when the user needs to expand the function, there is no need to change the source program, You can hook up the new feature to the menu by simply manipulating the parameter file.

A parameter file description

This procedure needs to borrow rib two parameter file to realize:

(1) a file (Menu.def) that describes each parameter in the menu, in the format described below:

! Belong to the menu code! Item order number! menu item Name! External Program Name! Subordinate Menu Code!

Description

1, if the menu code is "0", it means that this item belongs to the main menu

2, if the plugin name is "0", it means that the menu item corresponding to the process within the menu program or corresponding to a submenu;

3, if the subordinate menu code "0", it means that the menu item has no subordinate submenu;

4, the item order number also can use as the menu hotkey.

If the file menu.def has the following line:

! 0! 3! Format the disk! format/dev/rfd0135ds18! 0!

It indicates that the third item in the main menu is the formatted disk, and that the corresponding execution process is FORMAT/DEV/RFD0135DS18, and this item has no submenu.

If the user wants to make their own implementation of the query function of the program XXX Hook to the main menu item 4th, you can add the following line in the Menu.def:

! 0! 4! Inquire! Xxx! 0!

(2) A description file (menu.conf) for each menu parameter, and its format is as follows:

! Menu Code! The first level menu code! Border Flag! Menu Width! Number of menu lines! Number of menu Columns! Start the horizontal axis! Start ordinate!

Description

1, the border mark is "0" means no box, "1" means that there is a border;

2, the Superior menu Code "-1", indicating no superior menu;

3, such as menu code "0", indicating the main menu.

When the user is not satisfied with the menu display style, you can design a personalized interface by adjusting this file.

Related Article

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.