;源代码主要由两个窗体(frmMain主窗体和frmOption条码设置窗体)和两个模块组成(modGetScreen.bas、SysDLG32.bas)。考虑到篇幅,这里只列出部分较为关键的代码。
新建一个标准工程,添加一个名为(Microsoft Access BarCode Control9)的条形码部件,并添加一个条码控件到窗口,并将窗口改名为frmMain,如图所示。由于控件比较多,这里不便细说,详细内容请看源代码。
模块modGetScreen.bas代码如下:
Option Explicit
''声明BitBlt、GetDesktopWindow、GetWindowDC、ReleaseDC这几个API函数略
Public RegUser As Boolean
Sub GetObjImage1(Obj As Object, OwnerForm As PictureBox, Picture1 As PictureBox)
''hDC
Dim hWndDesk As Long
Dim hDCDesk As Long
''区域表达变量
Dim x As Long
Dim y As Long
Dim w As Long
Dim h As Long
x = Obj.Left Screen.TwipsPerPixelX
y = Obj.Top Screen.TwipsPerPixelY
w = Obj.Width Screen.TwipsPerPixelX
h = Obj.Height Screen.TwipsPerPixelY
hDCDesk = OwnerForm.hdc
''取出图像
Call BitBlt(Picture1.hdc, 0, 0, w, h, hDCDesk, x, y, vbSrcCopy)
Call ReleaseDC(hWndDesk, hDCDesk)
End Sub
主窗体frmMain.frm部分代码如下:
Private Sub cmdPrint_Click()
''生成条形码图像
Dim r As Long, i As Integer, t As String,cfile As String ''临时变量
t = BarCode
For i = 0 To Val(Times) - 1
BarCode1.Value = BarCode + i
DoEvents
Picture1.Refresh
GetObjImage1 BarCode1, Conel, Picture1
If RegUser = False Then ''如果未
注册添加MASK标记
Picture1.PaintPicture Picture2.Picture, 300, 300
&nb