
Home |
|
PegComboBox
|

Examples |

Index |
|
 |
|
|
 |
|
Overview |
Derived from class
PegVertList
|
 |
|
The PegComboBox class provides a compact container for
a list of objects. The PegComboBox object must be
"opened" to view the list of objects. The combo box is opened via the
drop down arrow to the right of the combo box. The combo box is "closed"
once an object is selected from the list, leaving only the selected object visible
in the combo box. The combo box is also closed when it loses input focus.
The PegComboBox object sends a signal notification to its parent
window if both the PegComboBox and the child selected from its
list have a non-zero object ID.
The last child object added
to the combo box will be displayed at the top of the combo box
if the Add() function is used to add children.
The order of display can be reversed
by using the function AddToEnd() to add children to the combo box.
If PegPrompt objects
are added to a PegComboBox, the style flags for the
PegPrompt objects should
include FF_NONE|AF_ENABLED|TJ_LEFT for correct display.
Although a PegPrompt object is normally not selectable,
the AF_ENABLED style flag must be used
when the PegPrompt object is added to a combo box
so that the prompt object can be selected.
|
|
 |
 |
|
PegVertList
PegHorzList
PegWindow
The PegComboBox class supports
the following style flags:
FF_NONE | No frame. |
FF_THIN | Thin frame. |
FF_THICK | Thick 3D frame. |
FF_RAISED | Raised 3D frame. |
FF_RECESSED | Recessed 3D frame. |
Note that scrolling of the object list within a PegComboBox object
is enabled using the SetScrollMode() function, as for all
windows derived from the PegWindow class.
The PegComboBox class generates
the following signals:
PSF_LIST_SELECT | Sent by PegList
derived objects (including PegHorzList,
PegVertList and PegComboBox) when
list item is selected. |
A PSF_LIST_SELECT signal is sent to the parent of
a PegComboBox object if, and only if, both the
combo box AND the child object in the combo box list
have a non-zero object ID.
The signal message contains the following information:
Message.lData |
Not used. |
Message.iData |
Object ID of the selected list item. |
Message.pSource |
Pointer to the PegComboBox object. |
|
Constructors:
 |
 |
PegComboBox(const PegRect &Rect,
|
| |

WORD wId = 0,
|
| |

WORD wStyle = FF_THIN)
|
This constructor creates a
PegComboBox object at a specific location within a
rectangle specified by parameter Rect.
The vertical dimension of the rectangle determines the height
of the combo box when open. The closed height is determined by the
tallest of the child objects within the combo box.
Public Functions:
 |
 |
void Draw(void)
|
The PegComboBox class overrides
the Draw() function to display the combo box border.
 |
 |
SIGNED GetOpenHeight(void) {return miOpenHeight;}
|
This inline function
returns the height (in pixels) of the combo box when open.
 |
 |
BOOL IsOpen(void) {return mbOpen;}
|
This inline function
returns TRUE if the combo box is currently open, else FALSE.
 |
 |
virtual SIGNED Message(const PegMessage &Mesg)
|
The PegComboBox class overrides
the Message() function to catch the drop down arrow
selection message and the PM_KILLFOCUS system message,
both of which require the combo box to be opened or closed and redrawn.
 |
 |
void Resize(PegRect NewSize)
|
The PegComboBox class overrides
the Resize() function to keep the drop down arrow button
positioned at the upper right hand corner of the combo box when the
combo box is moved.
Protected Members:
 |
 |
BOOL mbOpen
|
This boolean variable is TRUE
if the combo box is open or FALSE if it is closed.
 |
 |
SIGNED miOpenHeight
|
This variable provides the height (in pixels) of the combo box when open.
 |
 |
SIGNED miCloseHeight
|
This variable provides the height (in pixels) of the combo box when closed.
The following example illustrates a PegComboBox object:

The following code fragment
creates a PegComboBox object and adds several PegPrompt
objects to the combo box.
The height of the open combo box will be 140 pixels.
The combo box is configured to include a vertical scroll bar.
The initial item selected will be item index 5 within the combo box.
Note that list items are numbered from 0.
void MyWindow::AddComboBox(void)
{
PegRect ListRect;
ListRect.Set(10, 10, 90, 150);
PEGCHAR cTemp[20];
pList = new PegComboBox(ListRect);
strcpy(cTemp, "Select");
for (iLoop = 10; iLoop > 0; iLoop--)
{
itoa(iLoop, cTemp + 6, 10);
pList->Add(new PegPrompt(0, 0, cTemp, iLoop,
FF_NONE | TJ_LEFT | AF_ENABLED | TT_COPY));
}
pList->SetScrollMode(WSM_VSCROLL);
pList->SetSelected(5);
Add(pList);
}