请问如何打印出覆盖在picturebox中的控件?

解决方案 »

  1.   

    控件.Zorder 0
    就可以在最上面了
      

  2.   

    添加另外一个PictureBox,然后:
    Private Const WM_PAINT = &HF
    Private Const WM_PRINT = &H317
    Private Const PRF_CLIENT = &H4&
    Private Const PRF_CHILDREN = &H10&
    Private Const PRF_OWNED = &H20&
    Private Const PHYSICALOFFSETX As Long = 112
    Private Const PHYSICALOFFSETY As Long = 113
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd _
     As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nindex _
     As Long) As Long
    private Sub Form_Load()
        Picture1.AutoRedraw = True
        Picture2.AutoRedraw = True
        Picture2.BorderStyle = 0
        Picture2.Visible = False
    End Sub
    Private Sub Command2_Click()
        Dim retval As Long, xmargin As Single, ymargin As Single
        Dim x As Single, y As Single
        x = 1: y = 1
        With Printer
          .ScaleMode = vbInches
          xmargin = GetDeviceCaps(.hdc, PHYSICALOFFSETX)
          xmargin = (xmargin * .TwipsPerPixelX) / 1440
          ymargin = GetDeviceCaps(.hdc, PHYSICALOFFSETY)
          ymargin = (ymargin * .TwipsPerPixelY) / 1440
          Picture2.Width = Picture1.Width
          Picture2.Height = Picture1.Height
          DoEvents
          Picture1.SetFocus
          retval = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hdc, 0)
          retval = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hdc, _
          PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
          DoEvents
          Printer.Print ""
          .PaintPicture Picture2.Image, x - xmargin, y - ymargin
          .EndDoc
          End With
    End Sub
      

  3.   

    我想知道怎样把画在picturebox上的控件都打印出来
      

  4.   

    谢谢 laviewpbt(人一定要靠自己) 
    消化一下,本人太菜了
      

  5.   

    我将打印的PICTUREBOX2设置的大小大于屏幕,打印的时候可以如果第一次打印PICTUREBOX2的图片小于屏幕的话第二次打印(PICTUREBOX2的图片大于屏幕)是每问题的,但如果我继续打印,这次打印(PICTUREBOX2的图片小于屏幕),打印出来的东西会多出点图片,多出的是第二次打印时超出屏幕的图片
    我想问一下怎样能清空上一次打印的东西 你代码你写着Printer.Print "" 这是打印清空吧,但是为什么不能清空大于屏幕的东西,有什么办法啊?