在Windows窗体上以C语言打印 [英] Printing on Windows form in C
本文介绍了在Windows窗体上以C语言打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Windows窗体上打印事物列表,但我无法做到这一点.我正在使用textout当前进行打印,但每次仅打印一行.
这是我在WM_PAINT下所做的
大小写 WM_PAINT:
{
// 在窗口上绘制
hdc = BeginPaint(hMainWindow,& pStruct);
GetClientRect(hMainWindow,& amp; clientArea);
// 输出位置
TextOut(
hdc,// DC的句柄
nXStart,// 起始位置的x坐标
nYStart,// 起始位置的y坐标
textBuff,// 字符串
MAX_BUFF_LEN // 字符数
);
}
基本上我想将所有东西打印在新行上.我无法做到这一点.我添加到textBuff的所有内容都打印在一条水平线上.
使用DrawText
代替TextOut
.
并将所有行分组为一个唯一的字符串,并在每行末尾添加新的行字符:"\n"
.或"\r\n"
表示回车+新行.
Hi,
I am trying to print a list of things on the windows form but I am not able to do it. I am using textout to print currently but it only prints one line every time.
This is what I have done under WM_PAINT
case WM_PAINT:
{
// Draw on Window
hdc = BeginPaint(hMainWindow, &pStruct);
GetClientRect(hMainWindow, &clientArea);
// Output position
TextOut(
hdc, // handle to DC
nXStart, // x-coordinate of starting position
nYStart, // y-coordinate of starting position
textBuff, // character string
MAX_BUFF_LEN // number of characters
);
}
Basically I want a list of things to be printed on a new line.I am not able to do that.Everything I add to the textBuff gets printed in one horizontal line.
解决方案
UseDrawText
instead ofTextOut
.
And group all your lines in one unique string and add a new line character at the end of each line:"\n"
. Or"\r\n"
for carriage return + new line.
这篇关于在Windows窗体上以C语言打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文