Vb6 使用公共对话框打印picturebox打印空白页
我正在使用公共对话框控件打印picturebox的内容。下面是我的代码:Vb6 使用公共对话框打印picturebox打印空白页,vb6,Vb6,我正在使用公共对话框控件打印picturebox的内容。下面是我的代码: Private Sub mnuFilePrint_Click() StopPrinting = False ' Set CancelError is True On Error GoTo errhandler cmndlg.PrinterDefault = True ' Set flags cmndlg.Flags = cdlPDReturnDC + cdlPDNoPageNums
Private Sub mnuFilePrint_Click()
StopPrinting = False
' Set CancelError is True
On Error GoTo errhandler
cmndlg.PrinterDefault = True
' Set flags
cmndlg.Flags = cdlPDReturnDC + cdlPDNoPageNums
cmndlg.ShowPrinter
pigraph.Picture = picGraph.Image
Printer.Print picGraph.Picture
Printer.EndDoc
Exit Sub
errhandler:
Select Case Err
Case 32755 ' Dialog Cancelled
MsgBox "you cancelled the dialog box"
Case Else
MsgBox "Unexpected error. Err " & Err & " : " & Error
End Select
End Sub
单击“打印”按钮后,将打开“打印”对话框,我单击“打印”。但我收到的纸是空白的,除了页面顶部的随机数字串(每次打印时都会更改)
有人知道为什么会发生这个问题吗?我不应该得到一张空白页。谢谢。这里的问题是,要打印picturebox,行:
pigraph.Picture = picGraph.Image
Printer.Print picGraph.Picture
…对于这种情况是不正确的。必须用这一行替换它们:
Printer.PaintPicture picGraph.Image, 0, 0
这行打印图片盒