FormEdit.exe Implements Sizable Form Fields in Windows

ID: Q74797


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1


SUMMARY

FormEdit.exe is a sample program that 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.


MORE INFORMATION

Enter boilerplate text here!

FormEdit.exe

For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address

http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center.

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 query words:

Keywords : kbfile kbsample kb16bitonly kbCtrl kbSDKPlatform kbGrpUser
Version : WINDOWS:3.0,3.1
Platform : WINDOWS
Issue type :


Last Reviewed: December 4, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.