文档库 最新最全的文档下载
当前位置:文档库 › VB利用CodeSoft9的OCX控件打印标贴

VB利用CodeSoft9的OCX控件打印标贴

'OCX
'OCX (Object component exchange) is an ActiveX control.
'An OCX is an Object Linking and Embedding (OLE) custom control, a special-purpose program that can be created for use by applications running on Microsoft's Windows systems. OCXs provide such functions as handling scroll bar movement and window resizing.
'Microsoft now calls an OCX an ActiveX control, the component object under Microsoft's set of ActiveX technologies, of which the fundamental concept is the Component Object Model (COM) and, in a network, the Distributed Component Object Model (DCOM).
'An OCX or ActiveX control is actually implemented as a dynamic link library DLL module. (You can think of a DLL program as a "subprogram" that can be used by any number of application programs, each of which is a "container" for the DLL or OCX/ActiveX control "object.") Visual Basic and C++ are commonly used to write OCX or ActiveX controls.

'利用TkxOleCtrlEx.ocx控件实现打印,需要安装CS9,VB中才能添加TkxOleCtrlEx.ocx部件
Private Sub Command2_Click()
https://www.wendangku.net/doc/2a11610531.html,xOleCtrlEx1.ShowDialog lppxPrinterSetupDialog, 0 '打印机设置
End Sub

Private Sub Command3_Click()
Dim Printers As Variant
Dim Name As Variant
Dim Msg As String

printes = https://www.wendangku.net/doc/2a11610531.html,xOleCtrlEx1.Printers(lppxAllPrinters) '选择打印机
For nindex = LBound(Printers, 1) To UBound(Printers, 1)
Msg = Msg + Printers(nindex) + vbCrLf
Next
MsgBox Msg

Dim Variables As Variant
Variables = https://www.wendangku.net/doc/2a11610531.html,xOleCtrlEx1.Variables(lppxAllDataSource) '获取CS9模板里设置的变量

For Index = LBound(Variables, 1) To UBound(Variables, 1)
Msg = Msg + Variables(nindex, 0) + "=" + Variables(nindex, 1) + vbCrLf '得到模板里设置的变量名和变量值
Next

MsgBox Msg

Variables(0, 1) = "变量1"
https://www.wendangku.net/doc/2a11610531.html,xOleCtrlEx1.DocumentName = "c:\https://www.wendangku.net/doc/2a11610531.html,b" '获取模板文件路径
https://www.wendangku.net/doc/2a11610531.html,xOleCtrlEx1.UpdateVariables Variables '为变量赋值
https://www.wendangku.net/doc/2a11610531.html,xOleCtrlEx1.PrintDocument (1) '打印label

End Sub

相关文档
相关文档 最新文档