?
Solved

Printing IPictures using API

Posted on 1999-11-15
5
Medium Priority
?
291 Views
Last Modified: 2008-02-01
A have to print from VB not using printer object (such code does not work in ocx under delphi - don't know why). I have IPicture object and i need to print it to printer device context created previously by CreateDC. I am able to print rectangles, but IPicture does not want to print (it does not appear on printer).

I use for example following code:

    hDC = CreateDC("WINSPOOL", "\\SERVER\HP LaserJet 5MP", "", 0)
   
    StartDoc hDC, docInf
    StartPage hDC
    printerWidth = GetDeviceCaps(hDC, HORZRES)
    printerHeight = GetDeviceCaps(hDC, VERTRES)
   
    '----- this rectangle does print
   
    Rectangle hDC, printerLeft, printerTop, printerLeft + printerWidth, printerTop + printerHeight

    '----- this does not print

    pic.Render hdc, 0, 0, printerWidth, printerHeight, 0, 0, pic.width, pic.height, Null
   
    EndPage hDC
    EndDoc hDC        
    DeleteDC hDC

I also tried drawing picture using StretchBlt, but didn't suceed. Picture is o.k., as i am able to save it to file using SavePicture or print it using printer object.

Can someone please tell me, how to print IPictures on device context?

0
Comment
Question by:Rudla
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
mcrider earned 200 total points
ID: 2208804
Have you seen this microsot KB article (it's 16-bit, but you can use the 32-bit api calls...)

How to Print a VB Picture Control Using Windows API Functions
http://support.microsoft.com/support/kb/articles/Q77/0/60.ASP 

Cheers!

0
 
LVL 32

Expert Comment

by:Erick37
ID: 2208897
Are you able to print a standard StdPicture object (as opposed to the IPicture)?
0
 

Author Comment

by:Rudla
ID: 2213542
StdPicture picture is just class impementing Picture (IPictureDisp) and IPicture interface. So there's no difference between StdPicture and IPicture.

0
 

Author Comment

by:Rudla
ID: 2231271
Althought I thought that this is not very helpfull, i was able to use this example. Specifically one line comment saying:

'* StretchBlt requires pixel coordinates

Thank you.
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2231785
You're welcome! Thanks for the points!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question