如何使用VB打印出黑底白字

kxn 2008-09-20 01:27:03
以下两段代码同样使用了FontTransparent 属性,代码(1)可以实现黑底白字的效果,而代码(2)却不行。请问如何使用VB打印出黑底白字的效果?
(1)输出至PictureBox
Picture1.Line (1, 1)-(4500, 1500), RGB(0, 0, 0), BF
Picture1.CurrentX = 200
Picture1.CurrentY = 200
Picture1.FontBold = True
Picture1.FontName = "宋体"
Picture1.FontSize = 48
Picture1.ForeColor = RGB(255, 255, 255)
Picture1.FontTransparent = True
Picture1.Print "黑底白字"
(2)输出至打印机
Printer.Copies = 1
Printer.Line (1, 1)-(4500, 1500), RGB(0, 0, 0), BF
Printer.CurrentX = 200
Printer.CurrentY = 200
Printer.FontBold = True
Printer.FontName = "宋体"
Printer.FontSize = 48
Printer.ForeColor = RGB(255, 255, 255)
Printer.FontTransparent = True
Printer.Print "黑底白字"
Printer.EndDoc
...全文
886 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kxn 2008-09-24
  • 打赏
  • 举报
回复
谢谢大家的指教
zdingyun 2008-09-23
  • 打赏
  • 举报
回复
打印PictureBOX中的图片,达到LZ要求的白底黑字效果:
Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source

Private Sub Command1_Click() '打印图片
Picture1.Width = Picture1.Width
Picture1.Height = Picture1.Height
Picture1.AutoRedraw = True
BitBlt Picture1.hDC, 0, 0, Picture1.Width / Screen.TwipsPerPixelX, Picture1.Height / Screen.TwipsPerPixelY, Picture1.hDC, 0, 0, SRCCOPY
Picture1.AutoRedraw = False
Picture1.Refresh
Printer.PaintPicture Picture1.Image, 1000, 1000
Printer.EndDoc
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.Line (1, 1)-(4500, 1500), RGB(0, 0, 0), BF
Picture1.CurrentX = 200
Picture1.CurrentY = 200
Picture1.FontBold = True
Picture1.FontName = "宋体"
Picture1.FontSize = 48
Picture1.ForeColor = RGB(255, 255, 255)
Picture1.FontTransparent = True
Picture1.Print "黑底白字"
End Sub
现在还是人类 2008-09-21
  • 打赏
  • 举报
回复
没错,要输出的内容可以以图的方式处理好,然后在打印机输出处理好的图,要什么效果都容易。
zdingyun 2008-09-21
  • 打赏
  • 举报
回复
[Quote=引用楼主 kxn 的帖子:]
以下两段代码同样使用了FontTransparent 属性,代码(1)可以实现黑底白字的效果,而代码(2)却不行。请问如何使用VB打印出黑底白字的效果?
[/Quote]
PictureBox能执行,即使先用黑色画长方形,然后在黑色画长方形上用白色改写.

打印机,你打印了黑色,打印白色字(实际是该区域不打印黑色)在黑色上,实际仍然是黑色.你可采取打印PictureBox中的图片方
法(用API函数)来实现.
杨哥儿 2008-09-20
  • 打赏
  • 举报
回复
反白打印先画实心黑矩形,再输出白文字;注意先后顺序,且文字位置要自已计算。

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧