Hide

SftPrintPreview/OCX 1.0 - ActiveX Print Preview Control

Display
Print

SftPrintPreview.PrintDDB Method

Displays/prints a device dependent bitmap.

Syntax

VB.NETobject.PrintDDB(ByVal BitmapHandle As Integer, ByVal PrinterDC As Integer, ByVal XPrinterPix As OLE_XPOS_PIXELS, ByVal YPrinterPix As OLE_XPOS_PIXELS, ByVal WPrinterPix As OLE_XSIZE_PIXELS, ByVal HPrinterPix As OLE_YSIZE_PIXELS, ByVal WDispPix As Integer, ByVal HDispPix As Integer)
VBobject.PrintDDB(ByVal BitmapHandle As Long, ByVal PrinterDC As Long, ByVal XPrinterPix As OLE_XPOS_PIXELS, ByVal YPrinterPix As OLE_XPOS_PIXELS, ByVal WPrinterPix As OLE_XSIZE_PIXELS, ByVal HPrinterPix As OLE_YSIZE_PIXELS, ByVal WDispPix As Long, ByVal HDispPix As Long)
C#.NETvoid object.PrintDDB(int BitmapHandle, int PrinterDC, OLE_XPOS_PIXELS XPrinterPix, OLE_XPOS_PIXELS YPrinterPix, OLE_XSIZE_PIXELS WPrinterPix, OLE_YSIZE_PIXELS HPrinterPix, int WDispPix, int HDispPix);
VC++HRESULT object->PrintDDB(long BitmapHandle, long PrinterDC, OLE_XPOS_PIXELS XPrinterPix, OLE_XPOS_PIXELS YPrinterPix, OLE_XSIZE_PIXELS WPrinterPix, OLE_YSIZE_PIXELS HPrinterPix, long WDispPix, long HDispPix);
CHRESULT object->raw_PrintDDB(long BitmapHandle, long PrinterDC, OLE_XPOS_PIXELS XPrinterPix, OLE_XPOS_PIXELS YPrinterPix, OLE_XSIZE_PIXELS WPrinterPix, OLE_YSIZE_PIXELS HPrinterPix, long WDispPix, long HDispPix);

object

A SftPrintPreview object.

BitmapHandle

The bitmap handle of the bitmap to be printed.

PrinterDC

The printer device context.

XPrinterPix

The horizontal offset in printer coordinates, where the bitmap is printed.

YPrinterPix

The vertical offset in printer coordinates, where the bitmap is printed.

WPrinterPix

The width of the printed bitmap (in printer coordinates).

HPrinterPix

The height of the printed bitmap (in printer coordinates).

WDispPix

The width of the bitmap (in pixels, screen coordinates).

HDispPix

The height of the bitmap (in pixels, screen coordinates).

Comments

The PrintDDB method displays/prints a device dependent bitmap.

This method is not supported for use with Visual Basic 6.0

Device dependent bitmaps (screen bitmaps) can be printed using the PrintDDB method. Screen bitmaps cannot usually be printed without losing their original size (e.g., using BitBlt). The PrintDDB method is used to print bitmaps instead. When printing a screen bitmap, the width and height of the bitmap need to be scaled to retain their approximate original dimensions once printed.

The GetDDBSize method retrieves the display and print size of a device dependent bitmap.

Examples

VB.NET

            Dim hBmp As IntPtr = bmp.GetHbitmap()
            AxSftPrintPreview1.GetDDBSize(hBmp.ToInt32(), AxSftPrintPreview1.RenderingInfo.hDC, wPrinterPix, hPrinterPix, wDispPix, hDispPix)
            ' make sure entire image fits on remaining page
            If yPrinter + hPrinterPix > outRect.Bottom Then
                DeleteObject(hBmp)
                Exit While
            End If
            ' print bitmap, horizontally centered
            AxSftPrintPreview1.PrintDDB(hBmp.ToInt32(), AxSftPrintPreview1.RenderingInfo.hDC, xPrinter + (outRect.Width - wPrinterPix) / 2, _
                yPrinter, wPrinterPix, hPrinterPix, wDispPix, hDispPix)
            DeleteObject(hBmp)
            yPrinter += hPrinterPix ' next available space
        Else
            ' Print line
            ' get text size
            Dim s As SizeF = g.MeasureString(m_DrawText, m_PrintFont)

C#

            IntPtr hBmp = bmp.GetHbitmap();
            axSftPrintPreview1.GetDDBSize((int) hBmp, (int) axSftPrintPreview1.RenderingInfo.hDC, out wPrinterPix, out hPrinterPix, out wDispPix, out hDispPix);
            // make sure entire image fits on remaining page
            if (yPrinter + hPrinterPix > outRect.Bottom) {
                DeleteObject(hBmp);
                break;
            }
            // print bitmap, horizontally centered
            axSftPrintPreview1.PrintDDB((int) hBmp, axSftPrintPreview1.RenderingInfo.hDC, xPrinter +(outRect.Width-wPrinterPix)/2,
                yPrinter, wPrinterPix, hPrinterPix, wDispPix, hDispPix);
            DeleteObject(hBmp);
            yPrinter += hPrinterPix; // next available space
        }
        else
        {
            // Print line

C++

            // get bitmap size
            long wPrinterPix, hPrinterPix, wDispPix, hDispPix;
            m_vPrintPreview1->GetDDBSize((long)(HBITMAP)m_BitmapPage, RenderInfo.hDCPrinter, &wPrinterPix, &hPrinterPix, &wDispPix, &hDispPix);
            // make sure entire image fits on remaining page
            if (yPrinter + hPrinterPix > outRect.bottom)
                break;
            // print bitmap, horizontally centered
            m_vPrintPreview1->PrintDDB((long)(HBITMAP)m_BitmapPage, (long) pDC->m_hDC, xPrinter +((outRect.right-outRect.left)-wPrinterPix)/2,
                yPrinter, wPrinterPix, hPrinterPix, wDispPix, hDispPix);
            yPrinter += hPrinterPix; // next available space
        }
        else
        {
            // Print line
            // get text size
            RECT rect;

See Also SftPrintPreview Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.