Beruflich Dokumente
Kultur Dokumente
Presentation Outline
Introduction
The Button Class
Creating the Child Windows
Push Buttons
Check Boxes
Radio Buttons
Group Boxes
Controls and Colors
The Scroll Bar Class
The Edit Class
The Listbox Class
Introduction
The child window processes mouse and
keyboard messages and notifies the parent
window when the child window's state has
changed.
In this way, the child window becomes a
high-level input device for the parent
window.
It encapsulates a specific functionality with
regard to its graphical appearance on the
screen, its response to user input, and its
method of notifying another window when
an important input event has occurred.
TEXT ("button")
Window text
button[i].szText
Window style
WS_CHILD WS_VISIBLE
button[i].iStyle
x position
cxChar
y position
cyChar * (1 + 2 * i)
Width
20 * xChar
Height
7 * yChar / 4
Parent window
hwnd
Child window ID
(HMENU) i
Instance handle
((LPCREATESTRUCT)
lParam) -> hInstance
Extra parameters
NULL
Push Buttons
Radio Buttons
A radio button is named after the row of buttons that were
once quite common on car radios. Each button on a car
radio is set for a different radio station, and only one button
can be pressed at a time. In dialog boxes, groups of radio
buttons are conventionally used to indicate mutually
exclusive options. Unlike check boxes, radio buttons do not
work as togglesthat is, when you click a radio button a
second time, its state remains unchanged.
The radio button looks very much like a check box except
that it contains a little circle rather than a box. A heavy dot
within the circle indicates that the radio button has been
checked. The radio button has the window style
BS_RADIOBUTTON or BS_AUTORADIOBUTTON, but the
latter is used only in dialog boxes.
Group Boxes
The group box, which has the
BS_GROUPBOX style, is an oddity in the
button class.
It neither processes mouse or keyboard
input nor sends WM_COMMAND
messages to its parent.
The group box is a rectangular outline with
its window text at the top. Group boxes are
often used to enclose other button controls.
System Colors
Windows maintains 29 system colors for painting
various parts of the display. You can obtain and set
these colors using GetSysColor and SetSysColors.
Identifiers defined in the windows header files
specify the system color. Setting a system color
with SetSysColors changes it only for the current
Windows session.
You can change some (but not all) system colors
using the Display section of the Windows Control
Panel. The selected colors are stored in the
Registry in Microsoft Windows NT and in the
WIN.INI file in Microsoft Windows 98. The Registry
and WIN.INI file use keywords for the 29 system
colors, followed by red, green, and blue values that
can range from 0 to 255.
COLOR_SCROLLBAR
Scrollbar
C0-C0-C0
COLOR_BACKGROUND
Background
00-80-80
COLOR_ACTIVECAPTION
ActiveTitle
00-00-80
COLOR_INACTIVECAPTION
InactiveTitle
80-80-80
COLOR_MENU
Menu
C0-C0-C0
COLOR_WINDOW
Window
FF-FF-FF
COLOR_WINDOWFRAME
WindowFrame
00-00-00
COLOR_MENUTEXT
MenuText
C0-C0-C0
COLOR_WINDOWTEXT
WindowText
00-00-00
COLOR_CAPTIONTEXT
TitleText
FF-FF-FF
COLOR_ACTIVEBORDER
ActiveBorder
C0-C0-C0
COLOR_INACTIVEBORDER
InactiveBorder
C0-C0-C0
COLOR_APPWORKSPACE
AppWorkspace
80-80-80
COLOR_HIGHLIGHT
Highlight
00-00-80
COLOR_HIGHLIGHTTEXT
HighlightText
FF-FF-FF
COLOR_BTNFACE
ButtonFace
C0-C0-C0
COLOR_BTNSHADOW
ButtonShadow
80-80-80
COLOR_GRAYTEXT
GrayText
80-80-80
Owner-Draw Buttons
If you want to have total control over the
visual appearance of a button but don't
want to bother with keyboard and mouse
logic, you can create a button with the
BS_OWNERDRAW style
If you need to display only an icon or a
bitmap in the button, you can use the
BS_ICON or BS_BITMAP style and set the
bitmap using the BM_SETIMAGE message.
The BS_OWNERDRAW button style,
allows complete freedom in drawing the
button.
After you've finished, you can turn the redraw flag back
on:
SendMessage (hwndList, WM_SETREDRAW, TRUE, 0) ;