关于折行打印的问题
怎样实现列标题和行限定字符长度的折行打印,即打印时满n个字符,标题和行都自动折行!谢谢! 问题点数:20、回复次数:4Top
1 楼mx_ch(☆梦幻天空☆)回复于 2002-06-02 17:28:57 得分 0
看看这个贴子,里面的这个函数是可用的Top
2 楼mx_ch(☆梦幻天空☆)回复于 2002-06-02 17:29:17 得分 0
http://www.csdn.net/expert/topic/771/771722.xml?temp=.4370233Top
3 楼oceanaut(海阔天空)回复于 2002-06-02 17:29:54 得分 15
//函数名:f_wordwrap
//参数1:as_text 要被处理的正文
//参数2:ai_charincol 一行放多少个字符(不包括回车)
//返回:as_tex 处理过的行
int i,li_len,j,k,l,li_totalrow
char lch_char,lch_next
string ls_wrappedtext,ls_next,ls_prev,ls_string
li_len = len(as_text)
j=0 //记ASCII大于127的字符个数
k=0 //记每一行的字符数
l =1 //每一行起始字符在正文中的位置
li_totalrow = 0
ls_wrappedtext = ""
for i=1 to li_len
lch_char = mid(as_text,i,1)
if asc(lch_char) > 127 then
j++
k++
else
if lch_char = /~r/ then
li_totalrow++
k++
ls_wrappedtext += mid(as_text,l,k)
j = 0
l += k
k =0
elseif lch_char = /~n/ then //新行
k++
ls_wrappedtext += mid(as_text,l,k)
l +=k
k --
else
k++
end if
end if
if k >= ai_charincol then//如一行已超过最大长度,则自动折行
lch_next = mid(as_text,i+1,1)
ls_next = mid(as_text,i+1,2)
ls_prev = mid(as_text,i,2)
if lch_next = /~r/ or lch_next = /~n/ then
continue
elseif lch_next = /./ or lch_next =/,/ or lch_next =/?/ or lch_next =/!/ &
or lch_next =/)/ or lch_next =/]/ or lch_next =/}/ or lch_next =/;/ &
or lch_next =/:/ or lch_next =/~// or lch_next =/~"/ then
if i <> li_len -1 then
continue
else
exit
end if
elseif ls_prev = /,/ or ls_prev =/。/ or ls_prev = /?/ &
or ls_prev = /!/ or ls_prev = /”/ or ls_prev =/’/ or &
ls_prev =/)/ or ls_prev = /;/ or ls_prev = /:/ or ls_prev = /、/ then
if i <> li_len -1 then
continue
else
exit
end if
elseif ls_next = /,/ or ls_next =/。/ or ls_next = /?/ &
or ls_next = /!/ or ls_next = /”/ or ls_next =/’/ or &
ls_next =/)/ or ls_next = /;/ or ls_next = /:/ or ls_next = /、/ then
if i <> li_len -2 then
j++
i++
k++
continue
else
exit
end if
else
if mod(j,2) = 0 then
ls_wrappedtext = ls_wrappedtext + mid(as_text,l,k) + /~r~n/
else
ls_string = mid(as_text,l,k -1)
ls_wrappedtext = ls_wrappedtext + mid(as_text,l,k -1) + /~r~n/
i --
k --
end if
j = 0
l += k
k = 0
li_totalrow ++
end if
end if
next
ls_wrappedtext = ls_wrappedtext + mid(as_text,l)
as_text = ls_wrappedtext
li_totalrow ++
return ls_wrappedtext
***别人的代码。Top
4 楼oceanaut(海阔天空)回复于 2002-06-02 17:30:37 得分 5
实现打印完一个DataWindow后不换页?
首先将datawindow的print输出到一个打印文件中,把其他的print也输入这个prn,然后,打印这个打印文件就行了。
datawindow_control1.object.datawindow.print.filename="c:\printfilepath\exam_1.prn"
datawindow_control2.object.datawindow.print.filename="c:\printfilepath\exam_1.prn"
dw_1.print()
dw_2.print()
run("print //d:\\printservename\sharename "c:\printfilepath\exam_1.prn")
//d:\\printservename\sharename打印机名
Top




