Results 1 to 4 of 4

Thread: picture box black when asked to print

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    uk
    Posts
    20

    Post

    The following code is used to print the chart, but it just prints black box?????


    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 GetDC Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
    Private Const SRCCOPY = &HCC0020
    Private Sub Command1_Click()
    Dim lDC As Long
    Dim W As Integer
    Dim H As Integer
    W = ScaleX(MSChart1.Width, vbTwips, vbPixels)
    H = ScaleY(MSChart1.Height, vbTwips, vbPixels)
    lDC = GetDC(MSChart1.hwnd)
    Picture1.AutoRedraw = True
    Picture1.Move 0, 0, MSChart1.Width, MSChart1.Height
    BitBlt Picture1.hdc, 0, 0, W, H, lDC, 0, 0, SRCCOPY
    Call ReleaseDC(MSChart1.hwnd, lDC)
    Picture1 = Picture1.Image
    Printer.PaintPicture Picture1, 0, 0
    Printer.EndDoc
    End Sub
    Thanks

    ------------------

  2. #2
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    Hi, your code works fine, the only thing taht I do where set AutoRedraw in desing mode and changed this line:

    Picture1.Move Picture1.Left, Picture1.Top, MSChart1.Width, MSChart1.Height

    'cause I wanted see the picture.

    The problem could be your printer.

    Why don't you use Graph32.ocx that cames with VB4 and works fine with VB5. If you wish I send you the needed files. this Graph32.ocx has his own method to print, and is what I'm using.

    Jefferson



  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    uk
    Posts
    20

    Post

    Jefferson could u please send the ocx files, thanks mate

    ------------------

  4. #4
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    OK!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width