以下两段代码同样使用了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
  

解决方案 »

  1.   

    PictureBox能执行,即使先用黑色画长方形,然后在黑色画长方形上用白色改写.

    打印机,你打印了黑色,打印白色字(实际是该区域不打印黑色)在黑色上,实际仍然是黑色.你可采取打印PictureBox中的图片方
    法(用API函数)来实现.
      

  2.   

    打印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 = sourcePrivate 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