Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ protected override unsafe bool RunDialog(IntPtr hwndOwner)
fixed (char* pBuffer = buffer)
{
result = PInvoke.GetLocaleInfoEx(
PInvoke.LOCALE_NAME_SYSTEM_DEFAULT,
string.Empty, // empty string == LOCALE_NAME_USER_DEFAULT, matches what the native PageSetupDlg dialog uses
Comment thread
LeafShi1 marked this conversation as resolved.
PInvoke.LOCALE_IMEASURE,
pBuffer,
buffer.Length);
Expand All @@ -299,6 +299,19 @@ protected override unsafe bool RunDialog(IntPtr hwndOwner)
}
Comment thread
LeafShi1 marked this conversation as resolved.
}

// Explicitly pass the unit flag to the native dialog so it operates in the same unit system
// that WinForms used when converting margins above. This ensures that the values written into
// rtMargin/rtMinMargin and the values read back in UpdateSettings are always in the same unit,
// regardless of how system-level and user-level locale settings may differ.
Comment thread
LeafShi1 marked this conversation as resolved.
Outdated
if (toUnit == PrinterUnit.HundredthsOfAMillimeter)
{
dialogSettings.Flags |= PAGESETUPDLG_FLAGS.PSD_INHUNDREDTHSOFMILLIMETERS;
}
else
{
dialogSettings.Flags |= PAGESETUPDLG_FLAGS.PSD_INTHOUSANDTHSOFINCHES;
}
Comment thread
LeafShi1 marked this conversation as resolved.
Outdated

if (MinMargins is not null)
{
Margins margins = PrinterUnitConvert.Convert(MinMargins, PrinterUnit.Display, toUnit);
Expand Down
Loading