当前位置:编程学习 > C#/ASP.NET >>

条形码打印若干问题期待解决。

用微软的条形码控件做条形码源,因为报表程序都已经写好了,用的是GDI技术,但是微软条形码控件不支持.PICTURE这个属性,请问如何能够把微软条形码控件用GDI打印出来呢?
如果实在不行,我现在考虑用PICTUREBOX中ADD微软条形码,这个已经实现了,但是PICTUREBOX.IMAGE属性是NOTHING的,如果想通过PICTUREBOX打印的话,怎么处理呢?

这里还是希望直接用GDI来打印条形码控件,实在不行了才考虑第二种方法.请这里的各位高人帮帮忙忙,先谢谢了! --------------------编程问答-------------------- 急,自己顶一下. --------------------编程问答-------------------- 网上也有支持打印的条形码控件,不妨搜索一下找找看吧。
帮顶! --------------------编程问答-------------------- 牛人啊,顶 --------------------编程问答-------------------- 我上传的资源里面有个科本条形码控件,我现在也在做一个这方面的软件,你看看这个控件是否合适,网上条码设计软件太贵了,想做个免费开源的,这个条码控件是免费的,功能不错 --------------------编程问答-------------------- 哦,免费的控件吗?请提供一下下载地址,谢谢,另外,这个控件具体如何在VB.NET中用呢? 烦请指教,谢谢 --------------------编程问答-------------------- 我下载了ASPOSE BARCODE 如何用呢? 望指点,谢 --------------------编程问答-------------------- 如果你要使用微软的条码控件进行打印的话,那你得先抓图然后再打印,给你段代码自己看吧。
     
 Private Declare Function BitBlt Lib "gdi32.dll" Alias "BitBlt" (ByVal _
    hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As _
    Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal _
    hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, _
    ByVal dwRop As System.Int32) As Long
    Dim memoryImage As Bitmap
        CaptureScreen()
        objPreview.ShowDialog()
    End Sub
    Private Sub CaptureScreen()
        Dim mygraphics As Graphics = Me.CreateGraphics()
        Dim s As Size = Me.Size
        memoryImage = New Bitmap(code.Width, code.Height, mygraphics)
        Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
        Dim dc1 As IntPtr = mygraphics.GetHdc
        Dim dc2 As IntPtr = memoryGraphics.GetHdc
        BitBlt(dc2, 0, 0, code.Width, _
           code.Height, dc1, code.Location.X, code.Location.Y, 13369376)

        mygraphics.ReleaseHdc(dc1)
        memoryGraphics.ReleaseHdc(dc2)
    End Sub
Private Sub objPrintDocument_PrintPage(ByVal sender As System.Object, ByVal e As PrintPageEventArgs)
        Dim sngYPosition As Single
        Dim sngXPosition As Single
        Dim sngLeftMargin As Single = e.MarginBounds.Left
        Dim sngTopMargin As Single = e.MarginBounds.Top
        Dim strLine As String = Nothing
        Dim objControl As Control
        For Each objControl In Me.Controls
            If TypeOf objControl Is Label Then
                strLine = objControl.Text
                sngXPosition = sngLeftMargin + objControl.Location.X
                sngYPosition = sngTopMargin + objControl.Location.Y
                Dim format As New StringFormat
                format.Alignment = StringAlignment.Center
                e.Graphics.DrawString(strLine, objControl.Font, Brushes.Red, objControl.Location.X, objControl.Location.Y)
                e.Graphics.DrawImage(memoryImage, code.Location.X, code.Location.Y)
            End If
        Next
        'memoryImage.Save("c:\1.bmp")
        'e.Graphics.DrawRectangle(Pens.Black, sngLeftMargin, sngTopMargin, Me.Width, Me.Height - 100)
        e.HasMorePages = False

    End Sub
   End Sub

--------------------编程问答-------------------- up --------------------编程问答-------------------- Mark. UP
--------------------编程问答-------------------- 我曾经写过一个39码(还是93码,搞不清了)的打印程序,效果还不错,我是自己一条线一条线画在纸上的,你觉得需要么,需要的话我把程序找出来,邮给你 --------------------编程问答-------------------- 给我啊!
E-MAIL:yuanxiong1863@163.com
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,