Sub printGFBJRpt(Obj As Object)
Dim TextW As Single ', TextH As Single,
Dim WordW As Single, LineW As Integer
Dim HalfW As Single, HalfH As Single
' Dim MulitPages As Integer '报表页数
' Dim PageRows As Integer '每页显示表格行数
' Dim SpaceRows As Integer '剩余行数
Dim i As Integer, j As Integer
Dim MidX As Single, MidY As Single '页面中心点坐标
Dim PageWidth As Single, PageHeight As Single
Dim Test
framGS.Visible = False
framPage.Visible = False
'获得页面宽高及中心点坐标
MidX = Obj.ScaleWidth / 2: MidY = Obj.ScaleHeight / 2
PageWidth = Obj.ScaleWidth - 2 * PageSideDx
PageHeight = Obj.ScaleHeight - 2 * PageSideDy ' - PageSideDy ' 多减一个用于打印第几页
Obj.CurrentX = 0: Obj.CurrentY = 0
'打印标题
If bOutToPRN Then
SetFontSize Obj, "大标题", 1
Else
SetFontSize Obj, "大标题", XRate
End If
TextW = Obj.TextWidth(TT)
TextH = Obj.TextHeight(TT)
RepheadHeight = TextH
HalfW = TextW / 2: HalfH = TextH / 2
Obj.CurrentX = MidX - HalfW: Obj.CurrentY = PageSideDy
Obj.Print TT '打印台头
'Obj.CurrentX = PageSideDx: Obj.CurrentY = Obj.CurrentY + 2 * TextH '换行
TextW = Obj.TextWidth(GFBJRpt.RptName)
TextH = Obj.TextHeight(GFBJRpt.RptName)
RepheadHeight = TextH
HalfW = TextW / 2: HalfH = TextH / 2
Obj.CurrentX = MidX - HalfW
Obj.CurrentY = PageSideDy + TextH
Obj.Print GFBJRpt.RptName '打印报表标题
'打印小标题
If bOutToPRN Then
SetFontSize Obj, "小标题", 1
Else
SetFontSize Obj, "小标题", XRate
End If
TextW = Obj.TextWidth(GFBJRpt.DataZero)
TextH = Obj.TextHeight(GFBJRpt.DataZero)
HalfH = TextH / 2
If TextW <= PageWidth Then
Obj.CurrentX = PageSideDx
Obj.CurrentY = Obj.CurrentY + PageSideDy
Obj.Print GFBJRpt.DataZero '打印报表小标题1
Else
'改字号或分行适应行宽
End If
Obj.CurrentX = PageSideDx: Obj.CurrentY = Obj.CurrentY + HalfH '换半行
Test = Obj.CurrentY
'打印数据表格
Dim CellWidth As Single, CellHeight As Single
' Dim VTabRows As Integer,
Dim VTabCols As Integer
Dim SpaceHeight As Single, HeightTemp As Single
Dim PosX As Single, PosY As Single
Dim temp As Single
Obj.CurrentX = PageSideDx
Test = Obj.CurrentY
MulitPages = 1: PageRows = 0: SpaceRows = 0
If bOutToPRN Then
SetFontSize Obj, "正文", 1
Else
SetFontSize Obj, "正文", XRate
End If
TextH = Obj.TextHeight("字高测试")
'此处应判断空间大小
HeightTemp = Obj.CurrentY
SpaceHeight = PageHeight - HeightTemp - cm / 2 Obj.CurrentY = HeightTemp
CellHeight = mshCellHeight
MulitPages = 1 '只有一页
LabPage.Caption = "共 " & MulitPages & " 页"
FlagCmd BL = Val(Format$(PageWidth / TotalCellWidth, "0.0000"))
PosX = Obj.CurrentX: PosY = Obj.CurrentY '+ 850
PosX = PageSideDx
'第一行
CellHeight = TextH + 4 * mm
For i = 1 To 3
If i = 1 Then
CellWidth = MshCellWidth(1) * BL
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
TextW = Obj.TextWidth("所属区域")
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Obj.Print "所属区域"
PosX = PosX '+ MshCellWidth(1) * BL
ElseIf i = 2 Then
CellWidth = (TotalCellWidth - MshCellWidth(1)) * BL / 2
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
TextW = Obj.TextWidth("文件")
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Obj.Print "文件"
Else
CellWidth = (TotalCellWidth - MshCellWidth(1)) * BL / 2
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
temp = PosY + CellHeight
TextW = Obj.TextWidth("文件")
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Obj.Print "包裹"
End If
PosX = PosX + CellWidth
Next i
Me.Show
PosX = PageSideDx: PosY = temp 'Obj.CurrentY + CellHeight
'第二行
TextW = Obj.TextWidth("首0.5公斤")
CellHeight = TextH + 4 * mm
For i = 1 To 5
If i = 1 Then
CellWidth = MshCellWidth(1) * BL
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
Else
CellWidth = (TotalCellWidth - MshCellWidth(1)) * BL / 4
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
End If
temp = Obj.CurrentY
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Select Case i
Case 1
PosX = PosX + CellWidth
'Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
'Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Case 2
Obj.Print "首0.5公斤"
PosX = PosX + CellWidth
Case 3
Obj.Print "续0.5公斤"
PosX = PosX + CellWidth
Case 4
Obj.Print "首0.5公斤"
PosX = PosX + CellWidth 'PageSideDx + CellWidth 'MshCellWidth(1) * BL
Case 5
Obj.Print "续0.5公斤"
'PosX = PageSideDx + CellWidth 'MshCellWidth(1) * BL
End Select
Next i
Me.Show
PosX = PageSideDx
'PosX = Obj.CurrentX
PosY = temp
For i = 1 To GFBJRpt.TableRows ' VTabRows
HeightTemp = PosY
For j = 1 To GFBJRpt.TableCols
TextW = Obj.TextWidth(GFBJRpt.TableData(i, j))
CellWidth = MshCellWidth(j) * BL
CellHeight = mshCellHeight
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
'Me.Show
Obj.Print GFBJRpt.TableData(i, j)
PosX = PosX + CellWidth
Next j
PosX = PageSideDx: PosY = HeightTemp + CellHeight
Next i
If bOutToPRN Then
SetFontSize Obj, "标注", 1
Else
SetFontSize Obj, "标注", XRate
End If
Obj.CurrentX = PageSideDx + (PageWidth - Obj.TextWidth("1/1")) / 2
Obj.CurrentY = PageSideDy + PageHeight - Obj.TextHeight("1/1") + 200
Obj.Print "1/1"
'7/4 CB
If bOutToPRN Then
If MulitPages <= 1 Then
Printer.EndDoc
Else
'Printer.NewPage
Printer.EndDoc
End If
Else
CurrentPage = 1
txtPage.Text = CurrentPage & "/" & MulitPages
' cmdMoveP.Enabled = False
End If
End Sub
Dim TextW As Single ', TextH As Single,
Dim WordW As Single, LineW As Integer
Dim HalfW As Single, HalfH As Single
' Dim MulitPages As Integer '报表页数
' Dim PageRows As Integer '每页显示表格行数
' Dim SpaceRows As Integer '剩余行数
Dim i As Integer, j As Integer
Dim MidX As Single, MidY As Single '页面中心点坐标
Dim PageWidth As Single, PageHeight As Single
Dim Test
framGS.Visible = False
framPage.Visible = False
'获得页面宽高及中心点坐标
MidX = Obj.ScaleWidth / 2: MidY = Obj.ScaleHeight / 2
PageWidth = Obj.ScaleWidth - 2 * PageSideDx
PageHeight = Obj.ScaleHeight - 2 * PageSideDy ' - PageSideDy ' 多减一个用于打印第几页
Obj.CurrentX = 0: Obj.CurrentY = 0
'打印标题
If bOutToPRN Then
SetFontSize Obj, "大标题", 1
Else
SetFontSize Obj, "大标题", XRate
End If
TextW = Obj.TextWidth(TT)
TextH = Obj.TextHeight(TT)
RepheadHeight = TextH
HalfW = TextW / 2: HalfH = TextH / 2
Obj.CurrentX = MidX - HalfW: Obj.CurrentY = PageSideDy
Obj.Print TT '打印台头
'Obj.CurrentX = PageSideDx: Obj.CurrentY = Obj.CurrentY + 2 * TextH '换行
TextW = Obj.TextWidth(GFBJRpt.RptName)
TextH = Obj.TextHeight(GFBJRpt.RptName)
RepheadHeight = TextH
HalfW = TextW / 2: HalfH = TextH / 2
Obj.CurrentX = MidX - HalfW
Obj.CurrentY = PageSideDy + TextH
Obj.Print GFBJRpt.RptName '打印报表标题
'打印小标题
If bOutToPRN Then
SetFontSize Obj, "小标题", 1
Else
SetFontSize Obj, "小标题", XRate
End If
TextW = Obj.TextWidth(GFBJRpt.DataZero)
TextH = Obj.TextHeight(GFBJRpt.DataZero)
HalfH = TextH / 2
If TextW <= PageWidth Then
Obj.CurrentX = PageSideDx
Obj.CurrentY = Obj.CurrentY + PageSideDy
Obj.Print GFBJRpt.DataZero '打印报表小标题1
Else
'改字号或分行适应行宽
End If
Obj.CurrentX = PageSideDx: Obj.CurrentY = Obj.CurrentY + HalfH '换半行
Test = Obj.CurrentY
'打印数据表格
Dim CellWidth As Single, CellHeight As Single
' Dim VTabRows As Integer,
Dim VTabCols As Integer
Dim SpaceHeight As Single, HeightTemp As Single
Dim PosX As Single, PosY As Single
Dim temp As Single
Obj.CurrentX = PageSideDx
Test = Obj.CurrentY
MulitPages = 1: PageRows = 0: SpaceRows = 0
If bOutToPRN Then
SetFontSize Obj, "正文", 1
Else
SetFontSize Obj, "正文", XRate
End If
TextH = Obj.TextHeight("字高测试")
'此处应判断空间大小
HeightTemp = Obj.CurrentY
SpaceHeight = PageHeight - HeightTemp - cm / 2 Obj.CurrentY = HeightTemp
CellHeight = mshCellHeight
MulitPages = 1 '只有一页
LabPage.Caption = "共 " & MulitPages & " 页"
FlagCmd BL = Val(Format$(PageWidth / TotalCellWidth, "0.0000"))
PosX = Obj.CurrentX: PosY = Obj.CurrentY '+ 850
PosX = PageSideDx
'第一行
CellHeight = TextH + 4 * mm
For i = 1 To 3
If i = 1 Then
CellWidth = MshCellWidth(1) * BL
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
TextW = Obj.TextWidth("所属区域")
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Obj.Print "所属区域"
PosX = PosX '+ MshCellWidth(1) * BL
ElseIf i = 2 Then
CellWidth = (TotalCellWidth - MshCellWidth(1)) * BL / 2
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
TextW = Obj.TextWidth("文件")
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Obj.Print "文件"
Else
CellWidth = (TotalCellWidth - MshCellWidth(1)) * BL / 2
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
temp = PosY + CellHeight
TextW = Obj.TextWidth("文件")
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Obj.Print "包裹"
End If
PosX = PosX + CellWidth
Next i
Me.Show
PosX = PageSideDx: PosY = temp 'Obj.CurrentY + CellHeight
'第二行
TextW = Obj.TextWidth("首0.5公斤")
CellHeight = TextH + 4 * mm
For i = 1 To 5
If i = 1 Then
CellWidth = MshCellWidth(1) * BL
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
Else
CellWidth = (TotalCellWidth - MshCellWidth(1)) * BL / 4
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
End If
temp = Obj.CurrentY
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Select Case i
Case 1
PosX = PosX + CellWidth
'Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
'Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
Case 2
Obj.Print "首0.5公斤"
PosX = PosX + CellWidth
Case 3
Obj.Print "续0.5公斤"
PosX = PosX + CellWidth
Case 4
Obj.Print "首0.5公斤"
PosX = PosX + CellWidth 'PageSideDx + CellWidth 'MshCellWidth(1) * BL
Case 5
Obj.Print "续0.5公斤"
'PosX = PageSideDx + CellWidth 'MshCellWidth(1) * BL
End Select
Next i
Me.Show
PosX = PageSideDx
'PosX = Obj.CurrentX
PosY = temp
For i = 1 To GFBJRpt.TableRows ' VTabRows
HeightTemp = PosY
For j = 1 To GFBJRpt.TableCols
TextW = Obj.TextWidth(GFBJRpt.TableData(i, j))
CellWidth = MshCellWidth(j) * BL
CellHeight = mshCellHeight
Obj.Line (PosX, PosY)-(PosX + CellWidth, PosY + CellHeight), , B
Obj.CurrentX = PosX + (CellWidth - TextW) / 2 '居中
Obj.CurrentY = PosY + (CellHeight - TextH) / 2 '2 * mm
'Me.Show
Obj.Print GFBJRpt.TableData(i, j)
PosX = PosX + CellWidth
Next j
PosX = PageSideDx: PosY = HeightTemp + CellHeight
Next i
If bOutToPRN Then
SetFontSize Obj, "标注", 1
Else
SetFontSize Obj, "标注", XRate
End If
Obj.CurrentX = PageSideDx + (PageWidth - Obj.TextWidth("1/1")) / 2
Obj.CurrentY = PageSideDy + PageHeight - Obj.TextHeight("1/1") + 200
Obj.Print "1/1"
'7/4 CB
If bOutToPRN Then
If MulitPages <= 1 Then
Printer.EndDoc
Else
'Printer.NewPage
Printer.EndDoc
End If
Else
CurrentPage = 1
txtPage.Text = CurrentPage & "/" & MulitPages
' cmdMoveP.Enabled = False
End If
End Sub
MoveToEx Printer.hDC, x, y, 0&
LineTo Printer.hDC, nx, ny
http://www.ylw.com.cn/yf/printview/printview.htm