While the printing code from notepad in a whole works pretty good, it has some minor issues
that make the printer output look really bad.
The patch determines the line height with a call to GetTextMetrics instead of GetTextExtentPoint32.
To determine the correct spacing between characters, it calls GetTextExtentPoint32 for every
individual character instead of using the hardcoded letter "M". This should fix spacing on
The current code only breaks a line if it finds a line break in the printed text. The patch adds
line breaks for lines that are longer than the current printing area.
When the current code checks if a page should be started, it only checks if the current page lies
in between the minimum and the maximum page returned by PrintDlg. This leads to the
situation that only one page is printed if the user selects "All" or "Selection" in the print dialog.
The patch adds two checks for "All" and "Selection", so that the corect number of pages is
The current code assumes that the corect mapping mode is already set. While this is
generally correct, since MM_TEXT is the default, we should assume the worst and set it
explicitly, just in case.
Additionally, the patch sets the nToPage to (WORD) - 1 for now.