I saw this paragraph in the DEVMODE docs which got me confused.
dmPaperSize
For printer devices only, selects the size of the paper to print on.
This member can be set to zero if the length and width of the paper
are both set by the dmPaperLength and dmPaperWidth members. Otherwise,
the dmPaperSize member can be set to a device specific value greater
than or equal to DMPAPER_USER or to one of the following predefined
values.
In it they say that dmPaperLength and dmPaperWidth are used only if dmPaperSize=0. The way they talk about it, it seems that dmPaperLength and dmPaperWidth should not be used with DMPAPER_USER.
That’s what I find confusing. I thought DMPAPER_USER means using a custom page size. Is it different from specifying 0? How is the custom size specified if dmPaperLength and dmPaperWidth can’t be used with DMPAPER_USER?
It looks like there is a Bug in the documentation.
According to The folks over at codeguru you should use DMPAPER_USER instead of 0. There are a number of code samples in that discussion thread.