- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
This is similar to my other post that's current - sorry to be a nuisance...
If I've got a bitmap in a memory device context, how do I send it to a printer? I can set up and connect to the desired printer OK, and I believe I need to use the function SetDIBitsToDevice to send the bitmap. What I'm stuck on are the 10th and 11th arguments, namely *lpvBits and *lpbmi. The example I've got relates these items to a .bmp file, but I have no idea how to connect them with a memory bitmap.
Many thanks in advance for any help.
Mike
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why not draw directly onto the printer device context?
Here is some code that works for me...
!***************************************************************************
!
! Print Dialog stuff...
!
integer*4 ::hDCPrn ! Handle for printer DC.
integer*4 ::cxPage, cyPage ! Size of page printed area.
integer*4 ::cPage! minimum dimension of page.
real*8 ::pwfract! Fraction of page width to use for printed image
character*40::DocName
type (T_DOCINFO)::di ! DOCINFO structure.
type (T_PRINTDLG)::pd! Print Dialog structure
type (T_RECT)rc
type (T_SIZE) PXY
!
integer*4 retlog, ihoriz, ivert
***************************************************************************
case (IDM_PRINTCOLOR)
!
! Initialise PRINTDLG structure.
!
pd.lStructSize = SIZEOF(pd)
pd.hwndOwner = hWnd
pd.Flags = PD_RETURNDC .OR. PD_NOPAGENUMS .OR. &
PD_NOSELECTION .OR. PD_PRINTSETUP
pd.nFromPage = 1
pd.nToPage = 1
pd.nMinPage = 1
pd.nMaxPage = 1
pd.nCopies = 1
pd.hInstance = NULL
pd.lpfnSetupHook = NULL
pd.lpSetupTemplateName = NULL
pd.lpfnPrintHook = NULL
pd.lpPrintTemplateName = NULL
retlog=PrintDlg(pd)
! Get handle for PRINTDLG Structure.
hdcPrn= pd%hDC
ihoriz= GetDeviceCaps(pD%hDc, PHYSICALWIDTH)
ivert= GetDeviceCaps(pD%hDc, PHYSICALHEIGHT)
! Set DocInfo data.
&n
bsp;DocName = 'Window Plot'C
di.cbSize = sizeof(di)
di.lpszDocName = loc(DocName)
di.lpszOutput = NULL
di.lpszDatatype = NULL
di.fwType = NULL
!
! Get size of printable area of page.
!
cxPage = GetDeviceCaps(hdcPrn, HORZRES)
cyPage = GetDeviceCaps(hdcPrn, VERTRES)
!
! select a fraction of the minimum page dimension to
! which the plot will be scaled.., default this to 3/4 in the present case or choose your own
pwfract=0.75
cpage=min(cxpage, cypage)*pwfract
!***********************************************************************************
!
! Prepare to plot to the printer.
!
retint = StartDoc(hdcPrn, di)
retint = StartPage(hdcPrn)
!
retint=SetMapMode(hdcPrn, MM_TEXT)
!
retlog=SetViewPortExtEx(hdcPrn,ihoriz, ivert, PXY)
!***********************************************************************************
! Prepare the scaling for the printer plot
!
! Put the code to set your origin and scale factors here.
! use ihoriz, ivert, cpage. Also need window size, ixwidth, iywidth obtained using GetClientRect, for example
retlog=getclientrect(hWnd,rc)
ixwidth=rc%right-rc%left
iywidth=rc%bottom-rc%top
!***********************************************************************************
! Plot the display, this time to the printer device context hDCPrn
!
! Put or CALL your drawing code here, passing hDCPrn to it instead of the window
!DC, and using the appropriate scale factors from integer plot numbers to printer units
!and appropriate origin
! Send the plot to the printer
retint = EndPage(hDCPrn)
retint = EndDoc(hDCprn)
!clean up
! Release the printer resources
retlog = DeleteDC(hDCprn)
MainWndProc=0

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page