Futurebasic/Language/Reference/wndblk

Syntax
ptr&amp; = WNDBLK

Description
This function returns a pointer to FutureBasic's internal Window Descriptor Block. The Window Descriptor Block is an array of Window Descriptors. Each Window Descriptor is a record which contains information about one of your program's windows; FutureBasic maintains a Window Descriptor for each window that you create using the statement. The structure of a Window Descriptor is as follows:

 The  element points to the window's window record, which is a structure that the MacOS Window Manager maintains for each open window. This is the same pointer that is returned by the  statement.

The  element is a handle to the first Edit Field Descriptor for the window. There is an Edit Field Descriptor for each edit field or picture field in the window; see below for more information. If there are no edit fields nor picture fields in the window,  is   (zero).

The  element is a handle to the currently active edit field or picture field (if any) in the window. This is the same as the handle returned by the  function when the window is active. If there is no active field in the window,  is   (zero).

The  element is a handle to the window's clip region. However, if the window's  attribute is set,   is   (zero).

 You can use the window's assigned ID number to determine the location of its Window Descriptor within the array. The first Window Descriptor in the array corresponds to "window #0," which is a special graphics port that is reserved for FutureBasic's internal use. The next element in the array corresponds to window #1; the next to window #2; and so on. Array elements that don't correspond to the ID of any existing window have undefined contents.

If you define a  record type as shown above, you can get a pointer to the Window Descriptor corresponding to window #  as follows:

Alternatively, you can use  to access the contents of the array using normal FutureBasic3 array syntax:

You can then use the syntax  to access an individual Window Descriptor.

Edit Field DescriptorsFutureBasic maintains an Edit Field Descriptor for each field that you create using the  statement or the   statement. For each window, there is a linked list of Edit Field Descriptors for the fields in that window; a handle to the first descriptor in the list can be found in the  element of the Window Descriptor record. The structure of an Edit Field Desciptor is as follows:

 The  element is a handle to the next Edit Field Descriptor in the list. If  is _nil, there are no more edit fields nor picture fields in this window.

The element is the field's ID number, as assigned by the   statement or the   statement.

The  element is the same as the type parameter specified in the   statement or the   statement (it defaults to   if no type was explicitly specified).

The element is the same as the   parameter specified in the   statement, or the justparameter specified in the   statement. It defaults to zero if the parameter wasn't specified.

The element is a handle to the field's TextEdit Record, which is a structure that the MacOS maintains for each open edit field. This is the same handle that is returned by the  function. Note that FutureBasic associates a TextEdit Record with picture fields as well as edit fields; you can use a picture field's TextEdit Record, for example, to determine the field's rectangle. See the "TextEdit" chapter of Inside Macintosh: Text for more information.



Example
The following function returns a count of the number of edit fields and picture fields in a specified window. It assumes that the  and   record types have been defined as shown above.

LOCAL FN EfCount(wndID) DIM wdPtr AS POINTER TO wDescriptor DIM efdH AS HANDLE TO efDescriptor count = 0 IF WINDOW(-wndID) = 0 THEN EXIT FN '(no such window) wdPtr = WNDBLK + (wndID * SIZEOF(wDescriptor)) efdH = wdPtr.efdHeadH&amp; WHILE efdH &lt;&gt; _nil INC(count) efdH = efdH..nextDescH&amp; WEND END FN = count

Note
Window Descriptors are maintained only for windows that are created using the statement, and Edit Field Descriptors are maintained only for edit fields/picture fields that are created using the   or   statement. If you create a window or an edit field using a MacOS Toolbox routine (such as NewWindow or TENew), there will be no Descriptor associated with it.