SAMPLE: Implementing Sizable Form Fields in WindowsLast reviewed: July 22, 1997Article ID: Q74797 |
3.00 3.10
WINDOWS
kbprg kbfile
The information in this article applies to:
SUMMARYThe sample program FORMEDIT in the Microsoft Software Library demonstrates one implementation of creating a form edit under Windows. Each form can be moved and sized with the mouse. This program uses two novel techniques to move and size the windows. These techniques are discussed in detail below. Download FORMEDIT.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:
MORE INFORMATIONEach field on the form is a child window. Each child window has an ID value that corresponds to a structure in a database. In this example, the database is a simple array.
Moving WindowsThe coordinates for each mouse message that is sent to the child window are translated into the corresponding coordinates in the parent window, then the message is passed to the parent window. In this manner, the parent window receives all mouse messages. If the parent window receives a WM_LBUTTONDOWN message, it checks to see if the point of the click is within a child window; if so, a state variable is set. When the WM_MOUSEMOVE message is received, the parent will check the state variable. If it set, the child window is moved to the new position selected with the mouse. Once the WM_LBUTTONUP message is received, the state variable is cleared. The child window responds to the WM_MOVE message by updating its record structure.
Sizing WindowsEach child window is created with the WS_THICKFRAME style bit. The WM_NCPAINT message is trapped, and the DrawCoolBorder() function is called in the place of standard nonclient painting processing. A three dimensional effect is drawn instead of the standard Windows sizing border. When the user moves the mouse over this area, the standard sizing arrows are displayed, and the user can change the window size using conventional click-and-drag methods. The child window responds to the WM_SIZE message by updating its record structure.
|
Additional reference words: 3.00 3.10 softlib FORMEDIT.EXE
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |