我正在尝试使用 TextOut
函数打印一个新行。
我试过了
TextOut(hDC, 10, 20, "Hello\nWorld", strlen(text));
但输出是“HelloWorld”。
如何使用 TextOut
打印新行?
最佳答案
简单。 TextOut
没有任何格式化功能。请改用 DrawText
。请参阅格式化标志以居中文本、计算矩形等。您不必使用 DT_EDITCONTROL
标志来完成 DrawText
格式化。例如,
HDC dc = ::GetDC(0);
RECT rc;
char *lpsz= "Hello\r\nWorld";
::SetRect(&rc,0,0,300,300);
::DrawText(dc,lpsz,::strlen(lpsz),&rc,DT_LEFT | DT_EXTERNALLEADING | DT_WORDBREAK);
::ReleaseDC(0,dc);
关于c - 使用 TextOut 函数打印新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7123343/