SAMPLE: Expanding the Size of a Dialog Box

Last reviewed: February 15, 1996
Article ID: Q35499
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

The EXPAND file in the Software Library demonstrates how to create a dialog box that expands to provide additional controls when the user clicks on a button control.

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

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

The remainder of this article describes the algorithm demonstrated in the EXPAND file.

MORE INFORMATION

To use an expanding dialog box in an application, perform the following two preparation steps:

  1. Design the entire dialog box and determine what controls will not be initially visible.

  2. Disable these hidden controls in the dialog box template by including the WS_DISABLED style bit. This prevents the TAB key or the appropriate mnemonic key from giving the focus to one of the hidden controls.

When the user clicks the "expand" button, perform the following five steps:

  1. Disable the expand button using EnableWindow(hWnd, FALSE).

  2. Enable the previously hidden controls using EnableWindow(hWnd, TRUE).

  3. Use SetFocus() to place the focus on the appropriate control.

  4. Use the following function to retrieve the current position and size of the dialog:

          GetWindowRect(hWndDlg, (LPRECT)&r);
    

  5. Use the following function to expand the dialog to its new size

          MoveWindow(hWndDlg, r.left, r.top, r.right - r.left,
    
                           (r.bottom - r.top) + change, TRUE);
    
       where "change" is the difference between the small size and the
       large size.
    
    
Note that the MoveWindow() function can be used to expand a window in any direction.


Additional reference words: 3.00 3.10 softlib EXPAND.EXE
KBCategory: kbprg kbfile
KBSubcategory: UsrDlgs


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: February 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.