说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

VB用 API 打开打印对话框

HTML文档下载 WORD文档下载 PDF文档下载
VB用 API 打开打印对话框

使用通用对话框控件当然可以打开打印对话框,不过要浪费更多的资源和增加了一个 OCX 部件。而用 API 会高效。
声明:
Declare Function PRINTDLG Lib "comdlg32.dll" Alias _
"PrintDlgA" (pPrintdlg As PRINTDLG) As Long
Type PRINTDLG
lStructSize As Long
hwndOwner As Long
hDevMode As Long
hDevNames As Long
hdc As Long
flags As Long
nFromPage As Integer
nToPage As Integer
nMinPage As Integer
nMaxPage As Integer
nCopies As Integer
hInstance As Long
lCustData As Long
lpfnPrintHook As Long
lpfnSetupHook As Long
lpPrintTemplateName As String
lpSetupTemplateName As String
hPrintTemplate As Long
hSetupTemplate As Long
End Type
使用:
Private Sub Command1_Click()
Dim p As PRINTDLG
p.lStructSize = Len(p)
p.hwndOwner = Me.hWnd
p.nFromPage = 1
p.nToPage = 1
p.nMinPage = 1
p.nMaxPage = 1
p.nCopies = 1
x = PRINTDLG(p)
Printer.Print Text1.Text
End Sub
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘