Printing IPictures using API

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?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Are you able to print a standard StdPicture object (as opposed to the IPicture)?
RudlaAuthor Commented:
StdPicture picture is just class impementing Picture (IPictureDisp) and IPicture interface. So there's no difference between StdPicture and IPicture.

RudlaAuthor Commented:
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.
You're welcome! Thanks for the points!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.