我没有读完你的程序,不过我用printer对象写打印的时候也遇到过类似的问题,我那个时候的问题是画的一个竖线太长了,用个循环分开画就可以了

解决方案 »

  1.   

    我也是没有办法呀!我这里没有有过printer进行过打印的,所以才到网上来
    看一看有没有会的!!!我是帮学校做的,就差这一点了,快要我的命了
    奇怪的是,如果把printer换成picturebox的话,就全部出现在屏幕上了,什么都
    不少,但就是在打印机上打印不完全。
    急,急,,急,,,,。
      

  2.   


    我看了你的代码,却发现在 VB 里面根本就没法看(格式全乱套!!而且很多不象是 VB 格式的东西),改掉又担心直接修改了你原来的错误,改得不明不白;把代码直接发送过来吧:[email protected]
    我想我可以尽快给你答复(不过如果你已经解决的话就不必发了)。
      

  3.   

    老兄,这样做太累了
    建议使用DataReport
    如果,你想挑战自己的话,我想你得用一些API函数,如:
    CreateDC 
    CreateBitmap 
    TextOut
    BitBlt
    在内存中构造图像,然后用BitBlt送到Printer对象上
      

  4.   

    在打印之前最好设置纸张大小,
    或定义
    printer.width=
    printer.height=
      

  5.   

    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
    Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = sourcePrivate Sub Command1_Click()
      Dim hDC As Long
      Dim hDC2 As Long
      Dim hBitmap As Long
      Dim rc As Long
      Dim Dspstr As String
      ' hDC = CreateDC("DISPLAY", 0, 0, lPd)
       hDC = GetDC(Me.hwnd)
       hDC2 = CreateCompatibleDC(hDC)
       hBitmap = CreateCompatibleBitmap(hDC, 200, 50)
       rc = SelectObject(hDC2, hBitmap)
       Dspstr = "This is a print test "
       rc = TextOut(hDC2, 10, 10, ByVal Dspstr, Len(Dspstr))
       
       Printer.Print "Head"
       
       BitBlt Printer.hDC, 10, 10, 200, 200, hDC2, 0, 0, SRCCOPY
       Printer.EndDoc
       
      rc = DeleteObject(hBitmap)
      rc = DeleteDC(hDC2)
      rc = DeleteDC(hDC)
      
    End Sub
      

  6.   

    Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
    Private Declare Function CreateBitmap Lib "gdi32" (ByVal nWidth As Long, ByVal nHeight As Long, ByVal nPlanes As Long, ByVal nBitCount As Long, lpBits As Any) As Long
    Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function SelectObject Lib "gdi32" (ByVal hDC As Long, ByVal hObject As Long) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDC As Long) As Long
    Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hDC As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
    Private Declare Function CreateFontIndirect Lib "gdi32" Alias _
        "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
    Private Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
    Private Type LOGFONT
        lfHeight As Long
        lfWidth As Long
        lfEscapement As Long
        lfOrientation As Long
        lfWeight As Long
        lfItalic As Byte
        lfUnderline As Byte
        lfStrikeOut As Byte
        lfCharSet As Byte
        lfOutPrecision As Byte
        lfClipPrecision As Byte
        lfQuality As Byte
        lfPitchAndFamily As Byte
        lfFaceName As String * 32
     End Type 'Charset constants
     'Values for lf.lfCharSet:
     Private Const ANSI_CHARSET = 0
     Private Const GB2312_CHARSET = 134
    Private Sub Command1_Click()
      Dim hDC As Long
      Dim hDC2 As Long
      Dim hBitmap As Long
      Dim rc As Long
      Dim Dspstr As String
      Dim hFont As Long
      Dim lf As LOGFONT   'hDC = CreateDC("DISPLAY", 0, 0, lPd)
       hDC = GetDC(Me.hwnd)
       hDC2 = CreateCompatibleDC(hDC)
       hBitmap = CreateCompatibleBitmap(hDC, 1000, 300)
       rc = SelectObject(hDC2, hBitmap)
            
       lf.lfCharSet = GB2312_CHARSET
       lf.lfFaceName = "ËÎÌå" & Chr$(0)
       lf.lfClipPrecision = 64
       lf.lfOutPrecision = 0
       lf.lfEscapement = 0
       lf.lfItalic = 0
       lf.lfWidth = 80
       lf.lfHeight = 160
       lf.lfOrientation = 0
       
       hFont = CreateFontIndirect(lf)
       rc = SelectObject(hDC2, hFont)
       
       
       Dspstr = "This is a print test "
       rc = TextOut(hDC2, 10, 10, ByVal Dspstr, Len(Dspstr))
       
       Printer.Print "Head"
       
       BitBlt Printer.hDC, 10, 10, 1000, 1000, hDC2, 0, 0, SRCCOPY
       Printer.EndDoc
       
      rc = DeleteObject(hBitmap)
      rc = DeleteDC(hDC2)
      rc = DeleteDC(hDC)
      
    End Sub
      

  7.   

    我早上做了一个尝试,发现直接有二个PictureBox可以很简单完成所想得到的功能
    方法是,一个PictureBox里放置另一个PictureBox,即Picture1是Picture2的父
    窗口或称为容器控件,调整picture2.width,height属性等同打印机的宽和高
    ,Picture2.scalemode=5--inch',picture2.AutoRedraw=True。接下来你就可以
    真接在picture2上绘制图像了,
    绘制好后用 {Printer.PaintPicture Picture2.Image, 10, 10}语句在打印机
    上打印