Without posting a lot of code, I will try to explain what I am experiencing.

I have an app that prints a custom size form (~ 4"x7") in both portrait and landscape orientation.

I provide the user a Page Setup menu item. Using the standard DocumentProperties() API function I acquire a populated DEVMODE structure from the last selected printer (or default for first time). In this structure, I test the for support in the following fields and set the appropriate structure member orientation, paper size, paper length and paper width.

I then use this member in a call to PageSetupDlg (). The dialog shows a correctly scaled page in the painted portion of this dialog and correctly responds when I select the page orientation. No problems here.

The problem occurs when I try to print using this same DEVMODE structure.

In portrait mode, there is no issue. However, when I select landscape mode, the text does in fact rotate BUT it is still printing on a form I assume MUST be in portrait mode. Therefore, the printing is all out of place.

Do I have to swap the width and length members in my DEVMODE structure as well? When I do this, the printing works fine. However, if I enable custom painting in the PageSetupDlg (), something gets confused. It is like the PageSetupDlg() expects the width and length to be set as in portrait mode (and correctly handles the painting) but the HDC from the CreateDC() calls expects me to swap the width and length to match the desired orientation. Should I be using the SetWorldTransform() on the printing HDC?

There was a post from several years ago about this but I didn't see any resolution. Any help would be appreciated.

Thanks,
Jim