[Translation] -Windows CE Program Design (3RD Edition) - 5.2 Public Controls (10)

xiaoxiao2021-04-10  518

Menu section translation: tellmenow

The menu strip control is introduced in Pocket PC 2000. From the appearance, the menu bar is different from the command bar lies in that it is located at the bottom of the window instead of the top. However, for programmers, there are many different programming interfaces for the menu bar. Because Pocket PC is popular and OEM vendors want to be able to create embedded systems with Pocket PC software, starting from Windows CE.NET 4.2, now the menu bar is released with the embedded version of Windows CE.

The menu strip is a combined and complicated control, which makes it not suitable for manual programming. The designer of the menu strip control seems to have intentionally through the code wizard and resource editor to complete most of the coding and resource generation of the menu strip control. Although this is most of the Windows programmer code, it is important to understand how the menu strip control is actually very important, especially when the tool does not fully meet the 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 appearance, especially the way of resources. For examples in the book, when I use the menu bar in the example, I will use the Code Wizard to generate the menu on the menu bar.

Before a diamond goes before writing a menu strip, I want to tell how to design controls. In many ways, the menu bar has different command strips controls used in the Windows CE system. First, the menu on the menu bar is not managed as a whole. Instead, although the menu is defined as a single resource, the menu strip manages the menu as a series of independent submenus.

When the corresponding button on the menu strip is in a point, each submenu is displayed as a pop-up menu displayed in the appropriate location. Therefore, in this sense, the menu bar is more like a toolbar than the command strip.

Users have little to see the difference between the menu strips and command strips, because the menu button is the leftmost of the menu strip in the desired way, adjacent to each other. However, for programmers, the focus of understanding difference is to understand how to manage and manipulate menu.

Another difference between the command bar is that the menu bar is not a sub-window for creating its windows. The menu strip control is actually a pop-up window created by the system and placed on the bottom of the screen. Creating a menu You can hide it by overwriting the menu bar. The part of 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 stripe on the desktop. This entanglement between the application with the menu strip is why the application using the menu bar control should be manually adjusted.

Figure 5-5 shows the menu bar on the Pocket PC, and Figure 5-6 shows the interface when running the same application in the embedded system. The two menu strips to be discussed is still existing. Figure 5-5 (): Menu bar on the Pocket PC device. Figure 5-5 (): Menu bar on the embedded system.

The menu strip on the Pocket PC contains the soft keyboard (SIP) button on the left side of the control. On the embedded device, the SIP button is on the task bar, not on the menu bar. As an alternative to the SIP button, the menu bar on the embedded device has a [Close] button, which has a lightweight [Minimize] button on the top of the embedded device screen compared to the Pocket PC. Finally, even the very similar application of the same menu strip, there is a menu called [New] ([New]) on the left side of the PCKET PC version. This is an extension of the shell, but embedded devices are not supported. Because the [New] menu cannot be created in the [New] menu, the [New] menu is specified in the resource that is created to create a menu bar.

The other of the menu strips in the Pocket PC and the embedded device are the height of the menu strip. Because the menu bar is different from the system, it must be programmed to determine the height of the menu strip. Old Pocket PC applications, including programs in the first few editions of this book, assuming that the menu bar is 26 pixels. Since the menu control is used in a variety of systems, then this assumption is not established. One way to calculate the menu bar is to call the getWindowRect function with the menu handle as a parameter. The following code is in the WM_CREATE message processing function, the menu bar is calculated after the menu bar is created. Rect RectMB; getWindowRect (HWndMenubar, & RectMB); nmbheight = (RectMb.Bottom - RectMB.top);

转载请注明原文地址:https://www.9cbs.com/read-133401.html

New Post(0)