Multiline Button

Is there any way to make a dialogue box's PUSHBUTTON capable of displaying multiple lines of text?

I tried adding BS_MULTILINE to the style line of the .rc file for the dialogue box in question, but it was to no avail:
PUSHBUTTON "X\nX", IDCANCEL, 174, 35, 14, 35 still shows up as a single-line button in my dialogue box.

Below is the entire .rc file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<Windows.h>
#include "resource.h"
#ifndef IDC_STATIC
#define IDC_STATIC				-1
#endif
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 239, 250
STYLE BS_MULTILINE | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "關於"
FONT 8, "MS Sans Serif"
{
	DEFPUSHBUTTON "確定", IDOK, 174, 18, 50, 14
	PUSHBUTTON "取\n消", IDCANCEL, 174, 35, 14, 35
	GROUPBOX "", IDC_STATIC, 7, 7, 225, 225
	CTEXT "關\n於\n這\n個\n程\n式\n:", IDC_STATIC, 35, 18, 14, 200
	CTEXT "這\n個\n例\n子\n程\n式\n表\n明\n對\n話\n方\n塊\n的\n應\n用\n。\n|\n|\n鍾\n益\n飛", IDC_STATIC, 16, 18, 14, 200
}
Last edited on
how are you sending input to the dialog box.? If you are using a buffer (which is done generally), you can concatenate multiple lines in that buffer. Do use \r\n at end of every line. Then you can simply send the buffer to dialog box.

BR//
Abhishek
Okay, clearly I'm a novice programmer. I found that, not only was I placing BS_MULTILINE in the wrong place, but also that I needed to add spaces after each character (i.e. PUSHBUTTON "X X " instead of PUSHBUTTON "XX") in order to achieve the desired effect. Below is the code in which I successfully created a multiline button:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<Windows.h>
#include "resource.h"
#ifndef IDC_STATIC
#define IDC_STATIC				-1
#endif
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 114, 239
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "關於"
FONT 8, "MS Sans Serif"
{
	DEFPUSHBUTTON "確 定 ", IDOK, 20, 59, 17, 50, BS_MULTILINE
	PUSHBUTTON "取 消 ", IDCANCEL, 20, 116, 17, 50, BS_MULTILINE
	GROUPBOX "", IDC_STATIC, 7, 7, 100, 225
	CTEXT "關\n於\n這\n個\n程\n式\n:", IDC_STATIC, 69, 18, 14, 200
	CTEXT "這\n個\n例\n子\n程\n式\n表\n明\n對\n話\n方\n塊\n的\n應\n用\n。\n|\n|\n鍾\n益\n飛", IDC_STATIC, 50, 18, 14, 200
}
Last edited on
That's good you have done it successfully. I want to ask one thing. I am trying the same thing. I have an multi line edit box. However, the caret/cursor remains at the first character, rather then last character. If you have something to tell, please help me.

BR//
Abhishek
Topic archived. No new replies allowed.