-Windows CE programming (3rd edition)-5.2 Public controls (10)

Source: Internet
Author: User

Menu BarTranslation: tellmenow

The menu bar control is introduced in Pocket PC 2000. In terms of appearance, the menu bar differs from the command bar in that it is located at the bottom of the window rather than the top. However, for programmers, menu bar has many different programming interfaces. Because of the popularity of Pocket PC and the desire of OEMs to create embedded systems compatible with the Pocket PC software. net 4.2 and now the menu bar is released together with the embedded version of Windows CE.

Menu bar is a sophisticated and complex control, which makes it not suitable for manual programming. The designer of the menu bar control seems to also intentionally use the code wizard and resource editor to complete most of the encoding and resource generation of the menu bar control. Although this is the encoding method of most Windows programmers, it is still very important to understand how menu bar controls actually work, especially when tools cannot fully meet work needs. For this reason, in this section, I will describe the menu bar at the basic API level. Therefore, I can accurately describe the desired widget appearance, especially by using resources. For the examples later in the book, when I use a menu bar in the example, I will use the code Wizard to generate a menu bar.

Before writing a menu bar, I would like to briefly explain how to design controls. In many ways, the menu bar is different from other command bar controls used in Windows CE. First, the menu on the menu bar is not managed as a whole. On the contrary, although menus are defined as a single resource, menus are managed as a series of independent sub-menus.

When the corresponding button on the menu bar is clicked, each sub-menu is displayed as a pop-up menu in a proper position. Therefore, in this sense, a menu bar is more like a toolbar than a command bar.

Users rarely see the differences between Menu Bars and command bars, because menu buttons are placed on the leftmost of the menu bar in the desired way. However, for programmers, the key to understanding differences lies in understanding how to manage and manipulate menu entries.

Another difference between a menu bar and a command bar is that the menu bar is not a subwindow for creating its window. The menu bar control is actually a pop-up window created by the system and placed at the bottom of the screen. You can overwrite the menu bar to hide the window for creating a menu. The menu bar can be drawn to the upper layer of its owner. To avoid this, the application must adjust the window size to leave space for the menu bar on the desktop. The entanglement between an application and a menu bar is the reason why the application that uses the menu bar control needs to adjust its main window manually.

Figure 5-5 shows the menu bar on the Pocket PC, and figure 5-6 shows the interface for running the same application in the embedded system. The appearance of the two menu items to be discussed is slightly different.
Figure 5-5 (Omitted): menu bar on the Pocket PC device.
Figure 5-5 (Omitted): menu bar on the embedded system.

The menu bar on the Pocket PC contains the soft keyboard (SIP) button on the far left of the control. On an embedded device, the SIP button is on the task bar rather than the menu bar. As an alternative to the SIP button, the menu bar on the embedded device has a [close] button, compared with the Pocket PC, there is a lightweight [Minimization] button on the navigation bar at the top of the embedded device screen. Finally, even for applications with similar menu items, there is a menu named [new] ([new]) on the far left of the menu bar of the Pocket PC Edition. This is an extension of shell, but is not supported by embedded devices. Because of the lack of shell support, even if the [new] menu is specified in the resource used to create a menu bar, the [new] menu cannot be created.

Another difference between a menu bar in a Pocket PC and an embedded device is the height of the menu bar. Because the menu bar height varies with the system, it must be programmed to determine the height of the menu bar. Some older Pocket PC applications, including those in the previous versions of this book, are assumed that the menu bar is 26 pixels High. Now that menu bar controls are used in various systems, this assumption is not true. One way to calculate the menu bar height is to use the menu bar handle as a parameter to call the getwindowrect function. The following code is used in the wm_create message processing function to calculate the height after the menu bar is created.

Rect rectmb;
Getwindowrect (hwndmenubar, & rectmb );
Nmbheight = (rectmb. Bottom-rectmb. Top );

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.