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

Source: Internet
Author: User

Added band Translation: tellmenow
The rebarbandinfo structure is used to describe each zone in the control. by passing a rebarbandinfo structure array to the commamndbands_addbands function, you can add a zone to the application. The commandbands_addbands function prototype is as follows:
Bool commandbands_addbands (hwnd hwndcmdbands, hinstance hinst, uint cbands, lprebarbandinfo prbbi );
Before calling this function, you must enter the information of each band to be added to the control in the rebarbandinfo structure. The structure is defined as follows:
Typedef struct tagrebarbandinfo {
Uint cbsize;
Uint fmask;
Uint fstyle;
Colorref clrfore;
Colorref clrback;
Lptstr lptext;
Uint CCH;
Int iimage;
Hwnd hwndchild;
Uint cxminchild;
Uint cyminchild;
Uint cyminchild;
Uint CX;
Hbitmap hbmback;
Uint WID;
Uint cychild;
Uint cymaxchild;
Uint cyintegral;
Uint cxideal;
Lparam;
} Rebarbandinfo;
Fortunately, although the structure looks magnificent, many of the fields can be ignored because there are default values for uninitialized fields. Similar to the common Windows structure, cbsize needs to be filled with the structure size as a fault-tolerant security measure. The fmask field is filled with many flags to indicate which fields in the structure are filled with valid information. I will describe these signatures when discussing each domain.

If the rbbim_style flag is specified in the fmask field, the fstyle field must be filled with the style flag with a zone. The applicable labels are as follows:
The rbbs_break band starts from a new row.
The rbbs_fixedsize band cannot be adjusted. When this flag is specified, the "handle" with a zone is not displayed.
Rbbs_hidden after the command is created, the zone is invisible.
Rbbs_gripperalways has adjustable small handles, even if the command has only one belt.
Rbbs_nogripper has no adjustable small handle, so you cannot move the belt
Rbbs_novert if the ccs_vert style is used, the zone will not be displayed if the command Belt control is vertically displayed.
Rbbs_childedge draws edges at the top and bottom of the band
Rbbs_fixedbmp when the size of the band changes, the background bitmap of the band does not move.
Basically, these are self-explanatory. Although the command strip is usually displayed at the top of the window, they can be created as vertical command strip and displayed on the left of the window. In this case, the rbbs_novert style allows programmers to specify that the zone is not displayed when the command is taken in the vertical direction. The strip areas that contain menus or slightly wider controls are suitable for this sign, because they cannot be correctly displayed on the vertical strip areas.

The clrfore and clrback fields fill in the color information. When the application draws the band, the foreground color and background color are drawn with these colors. Note that these two fields are useful only when the rbbim_colors flag is set in the mask domain. These two fields and the hbmback fields used to specify the background bitmap for the band are useful only when the band contains transparent command lines. Otherwise, the command bar occupies most of the space in the zone and masks any background bitmap or color. In the "Configure independent strip" section, I will explain how to make the command bar transparent.

The lptext field specifies the optional text used to mark a single band. The text is directly displayed on the left side of the Strip. The iimage field is used to specify a bitmap displayed on the left of the band bar and fill the iimage field with the index of the image list contained in the image list control. When used together with the rbs_smartlabels style with the command control, text and bitmap display is more important. After the rbs_smartlabels style is specified, if the band is restored or maximized, the text is displayed. If the band is minimized, the bitmap is displayed. This technology is used by H/PC explorer to bring controls to its command.

The WID field is filled with the ID value of the zone. The band ID is very important, if you plan to configure them after creating the band ID or want to query their status. Even if you do not want to use a zone ID in the program, it is important to keep each zone ID unique because the control uses this ID to manage the zone. WID domain is checked only when the rbbim_id flag is set in the fmask domain.

If the default command bar control in the band needs to be replaced by another control, the hwndchild field is very useful. To replace the command bar control, you must first create a new control and then place the control's window handle in the hwndchild domain. The hwndchild domain is checked only when the rbbim_child flag is set in the fmask domain.

The cxminchild and cyminchild domains define the minimum sizes that can be reduced by the band. When using controls other than the default command bar, these two fields are useful for defining the height and minimum width of the band. The two domains are checked only when the rbbim_childsize flag is set in the fmask domain.

The cxideal domain is used when the zone is maximized by users. If this field is not initialized, the width of the control is extended when the command belt is maximized. By setting cxideal, the application can limit the maximum width of the band, which is very convenient for the control on the band only occupies part of the width of the whole band. This field is checked only when the rbbim_idealsize flag is set in the fmask domain.

The lparam domain provides a space to store the value of the band information defined by the application. This domain is checked only when the rbbim_lparam flag is set in the fmask domain.

Other fields in rebarbandinfo are used for more flexible rebar controls, not just command-belt controls. The following code creates a command-Belt control, initializes an array with three rebarbaninfo structures, and adds the zone to the control.
// Create a command bands control.
Hwndcb = commandbands_create (hinst, hwnd, idc_cmdband, rbs_smartlabels | rbs_varheight, himl );

// Initialize common rebarbandinfo structure fields.
For (I = 0; I <dim (RBI); I ++ ){
RBI [I]. cbsize = sizeof (rebarbandinfo );
RBI [I]. fmask = rbbim_id | rbbim_image | rbbim_size | rbbim_style;
RBI [I]. fstyle = rbbs_fixedbmp;
RBI [I]. WID = idb_cmdband + I;
}
// Initialize rebarbandinfo structure for each band.
// 1. Menu band.
RBI [0]. fstyle | = rbbs_nogripper;
RBI [0]. Cx = 130;
RBI [0]. iimage = 0;

// 2. Standard button band.
RBI [1]. fmask | = rbbim_text;
RBI [1]. Cx = 200;
RBI [1]. iimage = 1;
RBI [1]. lptext = text ("STD btns ");

// 3. Edit Control band.
Hwndchild = createwindow (text ("edit"), text ("Edit CTL "),
Ws_visible | ws_child | ws_border,
0, 0, 10, 5, hwnd, (hmenu) idc_editctl,
Hinst, null );

RBI [2]. fmask | = rbbim_text | rbbim_style | rbbim_childsize | rbbim_child;
RBI [2]. fstyle | = rbbs_childedge;
RBI [2]. hwndchild = hwndchild;
RBI [2]. cxminchild = 0;
RBI [2]. cyminchild = 25;
RBI [2]. cychild = 55;
RBI [2]. Cx = 130;
RBI [2]. iimage = 2;
RBI [2]. lptext = text ("edit field ");

// Add bands.
Commandbands_addbands (hwndcb, hinst, 3, RBI );
The command Belt control created in the above Code has three zones, one containing a menu, one containing a group of buttons, and the other using the edit control instead of the command bar. Controls are created using the rbs_smartlabels and rbs_varheight styles. When the command bar is minimized, a smart label displays an icon. When the command bar is not in the minimized state, a text icon is displayed. The rbs_varheight style allows different heights for each row on the control.

The fields used in the rebarbaninfo structure are initialized in a loop. Next, the remaining domain root in the structure is customized according to each band in the control. Initialization of the third band that contains the editing control is the most complex. More Initialization is required for this zone, because the editing control needs to adjust the size to match the standard height of the command bar controls in other zones.

Use the image List Index to initialize the iimage fields in each band. The image list is created and passed to the commandbands_create function. Text fields used in the second and third bands are marked and filled. The first band that contains a menu does not contain text tags because the menu does not need to be tagged. You can use the rbbs_nogripper style for the first band so that it cannot be moved on the control. This allows the menu band to be fixed and displayed in the appropriate position in the control.

Now that we have created a zone, it is time to check how to initialize them. (To be continued)

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.