Introduction to PM Programming - Jun 1994

Written by Larry Salomon Jr.

Introduction
The purpose of this column is to provide the readers out there who are not familiar with PM application development the information necessary to satisfy their curiosity, educate themselves, and give them an advantage over the documentation supplied by IBM. Of course, much of this stuff could probably be found in one of the many books out there, but the problem with books in general is that they don't answer the questions you have after you read the book the first time through.

I will gladly entertain feedback from the readers about what was "glossed over" or what was detailed well, what tangential topics need to be covered and what superfluous crap should have been removed. This feedback is essential in guaranteeing that you get what you pay for. :)

It should be said that you must not depend solely on this column to teach you how to develop PM applications; instead, this should be viewed as a supplement to your other information storehouses (books, the network conferences, etc.). Because this column must take a general approach, there will be some topics that you would like to see discussed that really do not belong here. Specific questions can be directed to the Scratch Patch, where an attempt to answer them will be made.

Last Month
Last month, we explored more of the PM APIs and began looking into the WC_ENTRYFIELD window class. This month, we will continue where we left off, and will continue in directions unknown; unknown, that is, unless you continue reading.

More Messages
Let us first begin by looking at the remaining entryfield messages.

Of Selections, Anchor Points, and Cursor Points
What is a selection? A selection is an area that is defined by the user. Any "objects" (defined by the context of the selection) that are contained within the selected area are defined to be selected. Any selection consists of two things: an anchor point, which is defined to be the point where the selection was started and is fixed, and a cursor point, which is defined to the be place where the cursor/pointer currently is and moves with the cursor/pointer. A selection is performed, according to CUA guidelines, using either the mouse or the keyboard. Using the mouse requires the user to press one of the buttons (usually the first) and hold the button while moving the mouse. When the selection has been made, the button is released. Using the keyboard, the user presses the Shift key while moving the cursor with the arrow keys. When the Shift key is released, the selection is completed.

There are other semantics associated with selections when using the mouse, but we will not discuss them here. The point of these definitions is to allow you to understand the purpose of the EM_SETSEL message. Its two parameters are slightly different that what was discussed above; if the anchor point is always before the cursor point ("before" is used, since the entryfield can be considered as being a one-dimensional stream of characters), then sMinSel is the anchor point and sMaxSel is the cursor point, otherwise the two are reversed.

Clipboard
For those of you who have no GUI experience, the clipboard is a temporary storage place for placing items to be used later in the same or other applications. Items of predefined, or application-defined formats, may be placed on the clipboard.

Its capabilities and interfaces are beyond the scope of this discussion, but it is important that you know what it is.

Text Limits
When you create an entryfield, by default it allows up to 32 characters maximum to be entered. If, however, you need more (or less) than this amount, you must first send it an EM_SETTEXTLIMIT message, which tells the entryfield to allocate more or less memory for its use.

Notifications
The entryfield also sends notifications to its owner. These notifications are listed below. focus. The notifications you will use the most often are the EN_CHANGE, EN_SETFOCUS, and EN_KILLFOCUS ones, although the others have their uses.
 * EN_CHANGE - this is sent whenever the entryfield's contents have changed.
 * EN_KILLFOCUS - this is sent whenever the entryfield is losing the input focus.
 * EN_MEMERROR - this is sent whenever the entryfield cannot allocate memory in response to an EM_SETTEXTLIMIT message.
 * EN_OVERFLOW - this is sent whenever an attempt to insert or paste more text than is allowed by the text limit is made.
 * EN_SCROLL - this is sent whenever the entryfield has scrolled from a call to WinScrollWindow, the cursor moving beyond the visible area, or when the text has changed.
 * EN_SETFOCUS - this is sent whenever the entryfield is gaining the input

Summary
This month, we finished looking at the entryfield messages, the notifications sent by the entryfield, and the concepts associated with the new messages. Next month, we will begin looking at the WC_LISTBOX class, and will continue with nameDlgProc.