Save System Resources with One Control per Control Class

Last reviewed: April 7, 1997
Article ID: Q80084
3.00 3.10 WINDOWS kbprg kbfile

The information in this article applies to:

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

SUMMARY

When an application is designed to gather a large amount of information from the user, the application can quickly consume many system resources due to the number of controls that it creates. Rather than creating many of the same type of control, an application can create one control and move it around.

The ONEEDIT sample in the Software/Data Library demonstrates this technique.

Download ONEEDIT.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 ONEEDIT.EXE (size: 36558 bytes) 
    
  • Internet (anonymous FTP)

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

For more information on what system resources are and how they are consumed, query this Knowledge Base on the following words:

   system and resources and heap and user and gdi

MORE INFORMATION

ONEEDIT demonstrates collecting data for multiple fields with a single edit control. It collects the following data by moving one control:

   Name (First, Middle, Last)
   Sex
   Social Security Number
   Birthday (Month, Day, Year)
   Address
   City
   State
   Zip Code
   Phone

The results of using this technique are transparent to the user; however, an application designed in this way consumes far fewer system resources because one edit control is used rather than many edit controls. Fifteen fewer controls are required by ONEEDIT because it uses this technique. This savings becomes more significant as the number of controls within an application increases.

The ONEEDIT source includes an application programmer's interface (API) that can be added to an application. For more information on the API, see the file API.TXT included in the ONEEDIT archive file.

The remainder of this article lists some of the other techniques implemented in ONEEDIT.

  1. Mouse support

    - The application performs hit-testing to move the edit control

         directly to any valid field.
    

  2. Supports both TAB and SHIFT+TAB keys to move from one field to another

    - TAB: forward - SHIFT+TAB: backward

  3. Input validation

    - If the value input for the State field does not correspond to a

         valid two-letter state abbreviation (as defined by the U. S.
         Postal Service), a Help dialog box is displayed listing the valid
         abbreviations.
    
    - Only a number (or a minus sign) is valid input in some fields

         (Social Security Number, Birthday, Zip Code, and Phone fields).
    
    - The value for the Sex field must be m, M, f, or F.

  4. Special case processing to move between fields of the Phone number

    - Automatically advances to next phone field when one field is

         filled.
    
    - BACKSPACE moves to the preceding phone field (for example, from

         the beginning of the prefix to the end of the area code).
    
    - Arrow keys allow movement between fields.

  5. Context-sensitive help in State field

    - The States Help can be invoked directly by pressing F2 when the

         cursor is in the State field.
    

  6. Icon automatically changes

    - The icon displayed in ONEEDIT client area changes depending on

         the contents of the Sex field.
    


Additional reference words: limit control window user heap 3.00 3.10
softlib ONEEDIT.EXE
KBCategory: kbprg kbfile
KBSubcategory: UsrRes
Keywords : UsrRes 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: April 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.