这样子的话,只能直接写屏了,把你的字段文取出来直接写屏。
测试中drawtext函数的最后一个参数取值为0x400(10进制1024)时返文本的尺寸,你要求是1024*768(横向1024点,纵向768点),可自行计算每行可显示多少字符。附测试附件。
源码:
Declare Integer GetDC In user32 Integer HWnd
Declare Integer CreateFont In gdi32;
INTEGER nHeight,;
INTEGER nWidth,;
INTEGER nEscapement,;
INTEGER nOrientation,;
INTEGER fnWeight,;
INTEGER fdwItalic,;
INTEGER fdwUnderline,;
INTEGER fdwStrikeOut,;
INTEGER fdwCharSet,;
INTEGER fdwOutputPrecision,;
INTEGER fdwClipPrecision,;
INTEGER fdwQuality,;
INTEGER fdwPitchAndFamily,;
STRING
lpszFace
Declare Integer SelectObject In gdi32;
INTEGER hdc,;
INTEGER hObject
Declare Integer DrawText In user32;
INTEGER
hDC,;
STRING
lpString,;
INTEGER
nCount,;
STRING
@ lpRect,;
INTEGER
uFormat
Local nhdc,nhobj
*start of font define
Local nheight,nwidth,nescapement,norientation,nweight,bltalic,bunderline,cstrikeout,ncharset,noutprecision,nclipprecision,nquality,npitchandfamily,lpszface
nheight=300
nwidth=0
nescapement=0
norientation=0
nweight=700&&FW_BOLD
bltalic=.F.
bunderline=.F.
cstrikeout=0
ncharset=134&&GB2312_CHARSET
noutprecision=0&&OUT_DEFAULT_PRECIS
nclipprecision=0&&CLIP_DEFAULT_PRECIS
nquality=0&&DEFAULT_QUALITY
npitchandfamily=0x0+0x32&&DEFAULT_PITCH | FF_SWISS
lpszface="宋体"
*end of font define
nhdc=getdc(0)
nhobj=createfont(nheight,nwidth,nescapement,norientation,nweight,bltalic,bunderline,cstrikeout,ncharset,noutprecision,nclipprecision,nquality,npitchandfamily,lpszface)
Local hfont
hfont=selectobject(nhdc,nhobj)
*start to draw text
Local rec,nlen,cstring,nstyle
*start of drawtext setting
rec=num2dword(0)+num2dword(768/2-nheight/2)+num2dword(1024)+num2dword(768)&&structure to save the area to draw
cstring="测试"+Chr(0)&&text to draw
nlen=Len(cstring)
nstyle=0x1+0x4&&the way to draw.DT_CENTER|DT_VCENTER,水平垂直居中
=drawtext(nhdc,@cstring,nlen,@rec,nstyle)
*user defined function
Function
num2dword (lnValue)
#Define m0
256
#Define m1
65536
#Define m2
16777216
Local b0, b1, b2, b3
b3 = Int(lnValue/m2)
b2 = Int((lnValue - b3 * m2)/m1)
b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
b0 = Mod(lnValue, m0)
Return Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)
Function
num2word (lnValue)
Return Chr(Mod(m.lnValue,256)) + Chr(Int(m.lnValue/256))