Hide

SftPrintPreview/OCX 1.0 - ActiveX Print Preview Control

Display
Print

SftPrintPreview.GetDDBSize Method

Retrieves the display and print size of a device dependent bitmap.

Syntax

VB.NETobject.GetDDBSize(ByVal BitmapHandle As Integer, ByVal PrinterDC As Integer, ByRef WPrinterPix As Integer, ByRef HPrinterPix As Integer, ByRef WDispPix As Integer, ByRef HDispPix As Integer)
VBobject.GetDDBSize(ByVal BitmapHandle As Long, ByVal PrinterDC As Long, WPrinterPix As Long, HPrinterPix As Long, WDispPix As Long, HDispPix As Long)
C#.NETvoid object.GetDDBSize(int BitmapHandle, int PrinterDC, out int WPrinterPix, out int HPrinterPix, out int WDispPix, out int HDispPix);
VC++HRESULT object->GetDDBSize(long BitmapHandle, long PrinterDC, long* WPrinterPix, long* HPrinterPix, long* WDispPix, long* HDispPix);
CHRESULT object->raw_GetDDBSize(long BitmapHandle, long PrinterDC, long* WPrinterPix, long* HPrinterPix, long* WDispPix, long* HDispPix);

object

A SftPrintPreview object.

BitmapHandle

The bitmap handle of the bitmap, for which the dimensions are returned.

PrinterDC

The printer device context.

WPrinterPix

Returns the printed width of the bitmap (in pixels).

HPrinterPix

Returns the printed height of the bitmap (in pixels).

WDispPix

Returns the screen width of the bitmap (in pixels).

HDispPix

Returns the screen height of the bitmap (in pixels).

Comments

The GetDDBSize method retrieves the display and print size of 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 not 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.

Examples

VB.NET

        If (Counter Mod (50 + 1)) = 0 Then
            ' Print a bitmap

            ' get bitmap size
            Dim bmp As Bitmap = New Bitmap(pictureBox1.Image)
            Dim wPrinterPix As Integer, hPrinterPix As Integer, wDispPix As Integer, hDispPix As Integer
            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)

C#

        if ((counter % (50+1)) == 0)
        {
            // Print a bitmap

            // get bitmap size
            Bitmap bmp = new Bitmap(pictureBox1.Image);
            int wPrinterPix, hPrinterPix, wDispPix, hDispPix;
            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,

C++

        }

        if ((counter % (50+1)) == 0)
        {
            // Print a bitmap

            // 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

See Also SftPrintPreview Object | Object Hierarchy


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