Notebook
The notebook control is designed to provide the user
with a visual organize of information, similar to a real notebook with
dividers. Information can be broken up into categories, with the major
tabs representing category headings. Information can be then
further broken up using minor tabs as teh subcategory headings.
The notebook consists of six major perts, as illustratedin Figure 22.1:
the binding, status line, intersection of pages, forward/backward page
buttons, major tabs, and minor tabs.
A notebook should be used to offer the user a choice of settings or to
present data that can be organized logically into categories or
groupes. Information that can be grouped together should be put into a
single tabbed section. Major tabs can be placed at any of the four
notebook sides; howeever, minor tabs always are placed perpendicular to
the major tabs. Page buttons are provided to allow the user to page
forward and backward between the notebook pages. Page buttons always
are located in the corner that is flanked by the back pages. The
bindings can either be spiral-bound or solid-bound, depending on the
specified style. A line of status text can be associated with each
notebook page. If more than one page exists in a category, the staus
line should be used to indicate this to the user; for example,
"Page 1 of 20". The status line can be left-justied, right-justified,
or centered along the bottom of the notebook. The last part of the
notebook is the insertion of the back pages, used to design a
landscape- or portrait-mode notebook. This feature gives the appearance
of a three-dimensional notebook. This intersection can be located at
any of the four corners. Figures 22.2 through 22.9 show the eight
possible combinations of styles.
-----
Table 22.1 Notebook Window Styles
Style
|
Description |
Backpage Orientation
|
BKS_BACKPAGESBR
|
Intersection of pages is located at the Bottom Right corner |
BKS_BACKPAGESBL
|
Intersection of pages is located at the Bottom Left corner |
BKS_BACKPAGESTR
|
Intersection of pages is located at the Top Right corner |
BKS_BACKPAGESTL
|
Intersection of pages is located at the Top Left corner |
Major Tab Side |
BKS_MAJORTABRIGHT
|
Major tabs are located on the Right side |
BKS_MAJORTABLEFT
|
Major tabs are located on the Left side |
BKS_MAJORTABTOP
|
Major tabs are located on the Top side |
BKS_MAJORTABBOTTOM
|
Major tabs are located on the Bottom side |
Tab Type
|
BKS_SQUARETABS
|
Notebook has Square edged tabs
|
BKS_ROUNDEDTABS
|
Notebook has Round edged tabs
|
BKS_POLYGONTABS
|
Notebook has Polygon edged tabs
|
Binding type
|
BKS_SOLIDBIND
|
Notebook has a Solid binding |
BKS_SPIRALBIND
|
Notebook has a Spiral binding |
Status
line text justification
|
BKS_STATUSTEXTLEFT
|
Notebook has the status text Left justify
|
BKS_STATUSTEXTRIGHT
|
Notebook has the status text Right justify |
BKS_STATUSTEXTCENTER
|
Notebook has the status text Centered |
Tab text justification
|
BKS_TABTEXTLEFT
|
Notebook has the tab text Left-justified |
BKS_TABTEXTRIGHT
|
Notebook has the tab text Right-justified |
BKS_TABTEXTCENTER
|
Notebook has the tab text centered
|
Tabbed dialog styles
|
BKS_TABBEDDIALOG
|
Tabbed dialog
|
BKS_BUTTONAREA
|
Reserve space for
|
The major and minor tabs can be customized somewhat. Thay can be square
or polygonal or have rounded corners. A tab can contain eithertext or
bitmaps. The text can be left-justified, right-justified, or centered.
If a bitmap is specified for the tab, the bitmap is sized automatically
to fill the tab. The dimensions for the tab need to be set using the
message BKM_SETDIMENTIONS. There is no automatic sizing of the tab for
text.
Notebook Pages
A notebook page is designed to be associated with a dialog box or
window. When a new page is selected in a notebook, the notebook
invalidates the new page, causing a WM_PAINT to be sent to the
procedure associated with newly selected page. When a notebook is
created, the initialization should handle the insertion of any needed
pages. If a page has a major or minor tab associated with it, this is
specified in the BKM_INSERTPAGE. The following code segment shows how
to insert a page.
ULONG ulPageID;
MRESULT mrReply;
mrReply = WinSendMsg(hwndNotebook,
BKM_INSERTPAGE,
(MPARAM)0,
MPFROM2SHORT(BKA_MAJOR|BKA_STATUSTEXTON,
BKA_FIRST)));
ulPageID = LONGFROMMR( mrReply);
If no major or minor tabs are specified, the new page becomes part of
the current section. Each page has a ulPageId
that is returned from the
BKM_INSERTPAGE message. This ID is used extensively in the notebook
messaging system.
The following example program illustates the
creation of a notebook.
NOTEBOOK.C
NOTEBOOK.RC
NOTEBOOK.H
NOTEBOOK.MAK
NOTEBOOK.DEF
Flipping Pages
In the WM_CONTROL message processing, the BKN_PAGESELECTED
notification code is sent each time a ne page is selected in the
notebook. We'll use this message as a signal to set the focus to the
specified dialog control for the selected page. The BKN_PAGESELECTED
notification code returns a pointer to the PAGESELECTNOTIFY structure.
The structure looks like this:
typedef struct _PAGESELECTNOTIFY /* pgsntfy */
{
HWND hwndBook; /* Notebook window handle */
ULONG ulPageIdCur; /* Previous top page id */
ULONG ulPageIdNew; /* New top Page id */
} PAGESELECTNOTIFY;
typedef PAGESELECTNOTIFY *PPAGESELECTNOTIFY;
The item we are interested in is the new top page ID, ulPageIdNew. This value is
used to query the window handle of the new page.
ppsnSelect = PVOIDFROMMP(mpParm2);
mrReply = WinSendMsg(ppsnSelect->hwndBook,
BKM_QUERYPAGEWINDOWHWND,
MPFROMLONG(ppsnSelect->ulPageIdNew),
0);
hwndPage = (HWND)PVOIDFROMMR(mrReply);
Once we have the window handel, we uery for the ID of the new top page.
If the ID belongs to the dialog, IDD_PERSONAL, we set the focus to the
first entry field, IDE_NAME. Otherwise, we know the dialog is the
TEAMOS2 dialog, and we set the focus to the first entry field in that
dialog, IDE_TEAMOS2.
usDlgId = WinQueryWindowUShort(hwndPage, QWS_ID);
if (usDlgId == IDD_PERSONAL)
{
WinSetFocus(HWND_DESKTOP,
WinWindowFromID(hwndPage, IDE_NAME));
} else {
WinSetFocus(HWND_DESKTOP,
WinWindowFromID(hwndPage, IDE_TEAMOS2));
} /* endif */
Creating a Notebook
The notebook is created using WinCreateWindow
after the client area has been created.
hwndNotebook = WinCreateWindow(hwndWnd,
WC_NOTEBOOK,
"",
BKS_SPIRALBIND | BKS_SQUARETABS | BKS_STATUSTEXTCENTER,
0,
0,
rclClient.xRight,
rclClient.yTop,
hwndWnd,
HWND_TOP,
ID_NOTEBOOK,
NULL,
NULL);
When the UM_CREATEDONE message is received, the first thing we do is
query the font size using GpiQueryFontMetrics.
Initialize Notbook
-----------
------------------
Table 19.1 Window Classes Covered in this Chapter
Constant
|
Description |
WC_COMBOBOX
|
Combo box. This is a combination of an entry field and a list
box.
It responds to all messages for both controls; additionally, there are
a few messages specifically for this class.
|
WC_FRAME
|
Frame. This window is used as the primary window for most
applications, and is also the basis for dialog windows. While the
typical interaction with this class is through subclassing, the frame window has
some useful messages for the developer.
|
WC_SCROLLBAR |
Scrollbar. This can be found in many applications, where the
environment is larger than the amount of screen allocated for the
application. scrollbars allow the user to change the visible portion by
scrolling the window.
|
WC_STATIC
|
Static window. This is a window whose contents are static,
that is, unchangable by the user. Typically, windows of this class are
textual in nature, but they can also be icons, bitmaps, and so on.
|
WC_TITLEBAR
|
Titlebar. On a standard
window, this window is placed between the system menu and the min/max
buttons. It provides a placement for the frame window text and also
allows quick access to window resizing, maximizing, and restoring.
|
===================
|
Figure 17.1 Entry fields.
|
The entry field does lask some capabilities that would be very nice to
have.
For example, being able to accept only certain types of text, having a
fully
functional picture string capability ('a la COBOL), and being
able
to force alltext to be upper- or lowercase would be handy. Chapter 27
addresses
the issue of adding function to an existing control and illustrates its
concepts
by an example that allows numeric input only in an entry field.
Table 17.1 shows the various styles available for the entry field.
Table 17.1 Entry Field Styles
Style |
DescrIption |
ES_LEFT |
Text is left justified.
|
ES_CENTER
|
Text is center justified.
|
ES_RIGHT
|
Text is right justified.
|
ES_AUTOSCROLL
|
Text is scrolled as the cursor moves beyond the visible
portion of the entry field.
|
ES_MARGIN
|
A margin is drawn around the entry field.
|
ES_AUTOTAB
|
When the maximum number of characters has been
entered, the input focus is passed to the next control with the
WS_TABSTOP style.
|
ES_READONLY
|
Text is not modifiable.
|
ES_COMMAND
|
The
entry is denoted a command entry field. The help Manager uses this to
provide
help for the cotents of the field, should the user request it. There
should
be only one entry field per window with this style.
|
ES_UNREADABLE
|
Text is displayed as a string of asterisks ( '*'
), one per character of actual text.
|
ES_AUTOSIZE
|
The entry field will size itself automatically
to insure that the text fits within the visible portion of the control.
|
ES_ANY
|
The
entry field can contain single- and double-byte characters. If the text
is
converted from an ASCII code to an EBCDIC code page, there may be an
overrun
in the converted text. Contrast this with ES_MIXED, where this is not
allowed.
|
ES_SBCS
|
Text is comprised of single-byte characters only.
|
ES_DBCS
|
Text is comprised of double-byte
characters only.
|
ES_MIXED
|
Text
can contain either single- or double-byte characters, wich may later be
converted
to or from an ASCII code page from or to EDCDIC code page.
|
Table 17.1 shows that numerous possibilities exist for creating entry
fields.
======================================
-----
The WM_INITDLG message processing initializes the box. The
first
step is to obtain the window handle of the list box using
WinWindowFromID.
The dialog box is the parent of all the controls in it. The macro
WinInsertLboxItem
is ashortened version of the function WinSendDlgItemMsg, designed
specially
to insert items into the list box.
===============================================================
An owner-draw style can be used for many of the Presentation Manager
controls.
LISTBOX.C
LISTBOX.RC
LISTBOX.H
LISTBOX.MAK
LISTBOX.DEF
|
Gotcha! |