Creating a Multiple Line Message Box

Last reviewed: November 2, 1995
Article ID: Q67210
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) versions 3.0 and 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

Message boxes are used to provide information to the user of an application. Error messages and warnings are also provided through message boxes. This article provides details on using message boxes in applications.

MORE INFORMATION

Message boxes are modal windows. When an application displays an application modal message box, which is the default message box type, the user cannot interact with any part of that application until the message box has been dismissed. However, the user may use the mouse or keyboard to activate another application and interact with it while the message box is displayed. Certain critical errors that may affect all of Windows are displayed in system modal message boxes. Windows will not perform any operations until the error condition is acknowledged and the system modal message box is dismissed.

There are times where it is necessary to display a long message in a message box. Windows does this when you start an MS-DOS-based application that uses graphics from inside an MS-DOS window. To break a message into many lines, insert a newline character into the message text. Here is a sample MessageBox() call:

   MessageBox(hWnd, "This is line 1.\nThis is line 2.", "App",
       MB_OK | MB_ICONQUESTION);

If the text of a message is too long for a single line, Windows will break the text into multiple lines.

System modal message boxes treat the newline character as any other. A newline character is displayed as a black block in the text. Because system modal message boxes are designed to work at all times, even under extremely low memory conditions, it does not provide the ability to display more than one line of text.


Additional reference words: 3.00 3.10 3.50 3.51 4.00 95
KBCategory: kbui
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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.