Fix single page print with modern dialog #5108
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3453, fixes #4235, fixes #4779, fixes #4817.
Setting a single page print range in modern UI results in SumatraPDF printing the current page.
It's caused by a change of behavior between legacy and modern print dialog, which, like you identified,
sets flags in a non expected way.
Here are flags hex values in different scenarios:
Single page range (2 or 2-2)
Legacy 0x00040006
Modern 0x00440014 -> Causing the issue because
PD_CURRENTPAGEis set.Other ranges
Legacy 0x00040006
Modern 0x00040016
Current page
Legacy 0x00440004
Not available in modern
All pages
Legacy 0x00040004
Modern 0x00040014
So, modern dialog sets
PD_CURRENTPAGEinstead ofPD_PAGENUMSwhen a single page range is entered,lpPageRangescontaining the custom range, withnFromPageandnToPageset to the chosen page.About code, note that
nPageRanges == 1check is added for precaution,it is always equal to 1 when legacy and modern dialogs set
PD_CURRENTPAGE.