The information in this article applies to:
- Microsoft Windows Software Development Kit (SDK) for Windows
versions 3.0 and 3.1
SUMMARY
The Microsoft Software Library contains the source code to a sample
program, MDITILE, that demonstrates how to implement an alternate tiling
scheme for the multiple document interface (MDI) of Windows version 3.0.
The alternate tiling scheme demonstrated in this sample attempts to tile
MDI child windows so they are wider than they are tall. The default MDI
tiling scheme sizes the child windows to be tall and narrow. This is
unsuitable for MDI applications based on text such as a word processor.
Download MDITILE.EXE, a self-extracting file, from the Microsoft Software
Library (MSL) on the following services:
MORE INFORMATION
The horizontally based tiling scheme implemented in this sample uses
the following eight-step procedure:
- Count the number of MDI child windows that are not iconic
(represented by an icon). These are the only windows affected by
tiling. This value is saved in "cKids."
- Find the next square (that is, a number "n," such that some integer
"x" is the square root, x*x == n), that is greater than the number
of windows to tile.
- Set a column value, "cCols," to "x-1," where "x" is the root of the
square found in step 2.
- Set a row counter, "cRows," to "cKids / cCols."
- Set a remainder counter, "cMulRows," to "cKids % cCols." This
accounts for the child windows that are not included in the base
grid of cCols by cRows.
- Get the dimensions of the client rectangle in which tiling is to
occur. Note that it may be desirable to reduce the size of this
rectangle to leave space at the bottom of the MDI client window for
a row of icons. Divide the vertical height of the rectangle by
cRows to get the child window height, and divide the horizontal
width of the rectangle by cCols to get the child window width.
- Loop through each row. In this row, the application will tile
cCols child windows. The value "cRows-cMulRows" is the number of
rows that can be created with cCols columns. If the rows that can
have cCols columns have already been done, then increment cCols
so that all remaining rows have an extra window. Since cMulRows
are left to tile, adding one window to each row account for all
remaining windows.
This is also why cCols was initially "x-1." If "cCols==x," then
the first rows (at the top of the window) would have more windows
than rows on the bottom. If this tiling scheme is desired, set
cCols to "x" as the assumed number of columns, then decrement
cCols when cMulRows have been tiled.
- Once the number of columns has been calculated, loop through the
columns, moving each window to the appropriate section of that row.
NOTE: It is preferable to move windows with BeginDeferWindowPos(),
DeferWindowPos(), and EndDeferWindowPos(), instead of many calls to
SetWindowPos(), because the visual effect of the window movement is much
cleaner.
|