SAMPLE: Implementing Sizable Form Fields in Windows

Last reviewed: July 22, 1997
Article ID: Q74797
3.00 3.10 WINDOWS kbprg kbfile

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

The 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:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download FORMEDIT.EXE (size: 30826 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get FORMEDIT.EXE (size: 30826 bytes) 
    

MORE INFORMATION

Each 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 Windows

The 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 Windows

Each 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
KBCategory: kbprg kbfile
KBSubcategory: UsrCtl
Keywords : kb16bitonly UsrCtl kbfile kbprg
Version : 3.00 3.10
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.