Link to home
Start Free TrialLog in
Avatar of Rudla
Rudla

asked on

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?

ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Are you able to print a standard StdPicture object (as opposed to the IPicture)?
Avatar of Rudla
Rudla

ASKER

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

Avatar of Rudla

ASKER

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!