Programming Tips - Windows: How to make the text in a MessageBox() more than one line

Date: 2009aug30 Update: 2025oct29 Language: C/C++ OS: Windows Platform: win32 Keywords: multiline, multi, line, message box Q. Windows: How to make the text in a MessageBox() more than one line A. Place \r\n between lines like this:
MessageBox(hwndParent, "Line One\r\nLine Two\r\nLine Three", "My Program", MB_OK);
Or you can use a macro:
#ifndef CRLF #define CRLF "\r\n" #endif MessageBox(hwndParent, "Line One" CRLF "Line Two" CRLF "Line Three", "My Program", MB_OK);
This is slightly more verbose but probably less error prone. It will look like this: