Board index » cppbuilder » Print Setup and printing a bitmap

Print Setup and printing a bitmap

I used some code from Damon Chandler (thanks) to access some printer
dimensions both just before and just after launching the printer setup
dialog and changing from portrait to landscape.  I was a little
surprised to see that the width and height didn't change.

I infer that I have to code the 90 degree rotation an internal bitmap
and then use StretchDIBit to move the image to the printer canvas- is
that correct?

Thanks,

Bob

--
Robert N. Lockwood
USDA Forest Service
Forest Fire Laboratory
Riverside, CA
RNLockw...@attglobal.net

 

Re:Print Setup and printing a bitmap


Hi Robert,

Quote
> I used some code from Damon Chandler (thanks) to access some printer
> dimensions both just before and just after launching the printer setup
> dialog and changing from portrait to landscape.  I was a little
> surprised to see that the width and height didn't change.

Use the PrintDlg API function directly, specifying the PD_RETURNDC flag -- use
the handle of the returned DC in the call to GetDeviceCaps()...

   PRINTDLG pd;
   ZeroMemory(&pd, sizeof(PRINTDLG));

    // initialize PRINTDLG
    pd.lStructSize = sizeof(PRINTDLG);
    pd.hwndOwner = Handle;
    pd.nCopies = 1;
    pd.nFromPage = 0xFFFF;
    pd.nToPage = 0xFFFF;
    pd.nMinPage = 1;
    pd.nMaxPage = 0xFFFF;
    pd.Flags = PD_RETURNDC;

    if (PrintDlg(&pd))
    {
        GetDeviceCaps(pd.hDC, ...);
        DeleteDC(pd.hDC);

        if (pd.hDevMode) GlobalFree(pd.hDevMode);
        if (pd.hDevNames) GlobalFree(pd.hDevNames);
    }

This will reflect the changed orientation.

Quote
> I infer that I have to code the 90 degree rotation an internal bitmap
> and then use StretchDIBit to move the image to the printer canvas- is
> that correct?

You wil need to render the image rotated -- changing the printer orientation
will not automatically rotate the image.

Good luck!

--
Damon Chandler
http://bcbcaq.freeservers.com

Other Threads