Display (Static) Control

The functionality of the display (static) control is embodied in the window class "static". Calling the control a 'static' is dicey because that conflicts with the C++ keyword 'static'. In i++, the static control is referred to as the display control. The display control primarily is used to display text that does not change (i.e. remains static). A display control does not accept mouse or keyboard input, nor does it notify its owner of events via the message message::command. When the mouse is moved over a display or clicked upon a display, the control intercepts the message message::nonclient_hit_test and returns the value hit_test::transparent. This causes the mouse message to be passed to the window underneath the control - which is usually the parent. Upon receiving such a message, the parent usually passes the message to the default window procedure; where, it is converted to a client area mouse message.

Display Styles

Rectangular Styles

The following six display styles cause a rectangle or a frame to be drawn in the area of the display control window (for these styles the window text is ignored).

display_style::rectangle_black The display field is filled using "black" rectangle.
display_style::rectangle_gray The display field is filled using a "gray" rectangle.
display_style::rectangle_white The display field is filled using a "white" rectangle.
display_style::frame_black The display field is surrounded by a "black" frame.
display_style::frame_gray The display field is surrounded by a "gray" frame.
display_style::frame_white The display field is surrounded by a "white" frame.

The terms 'Black', 'Gray' and 'White' do not mean that these are the actual colors used; rather, the colors that are used are based upon system colors and are shown in the table below.

Black system_color::three_d_dark_shadow
Gray system_color::button_shadow
White system_color::button_highlight

The upper-left corner of the rectangle begins at the x and y coordinates of the window's position relative to its parent. The styles display_style::EtchedHorizontal, display_style::etched_vertical and display_style::EtchedFrame may also be used with the rectangular styles to yield 3 dimensional shadowing effects.

Text Styles

Text styles for a display include display_style::left, display_style::right and display_style::center. These styles create left or right aligned text or centered text (respectively). The text of a display may be set via the function set_window_text and may be queried via the function get_window_text - which send the messages message::set_text and message::get_text respectively. The display control uses the function draw_text with styles draw_text_format::no_clip, draw_text_format::word_break and draw_text_format::expand_tabs to display its text. Text is word wrapped within the rectangle of the window.

The background of the windows of the text style is normally system_color::ButtonFace and the text is drawn in the color system_color::window_text. The message message::color_display may be intercepted by the parent and the color of the text may be changed by calling the function set_text_color. The color of the background may be changed by calling the function set_background_color or by returning the handle of a brush that is used to paint the background. This technique will be demonstrated in the sample of the next section.

Other Styles

Other display styles that apply only when the control occurs as part of a dialog are shown in the table below.

display_style::icon The display field contains an icon. The text specified for the display names an icon resource. The icon can be an animated cursor. The control ignores the specified width and height, and sizes itself to accommodate the icon.
display_style::bitmap The static control contains a bitmap. The text of the window names a bitmap resource. The width and height parameters are ignored and the control adjusts its size to accommodate the bitmap.
display_style::metafile The window is drawn using an enhanced metafile. The text of the window names the enhanced metafile. The metafile is scaled to fit the client area of the display control.
display_style::owner_draw The control is drawn by the owner window. The owner window is sent the message message::draw_item whenever painting is required.