-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: PrintDialog
not shown
#2851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlg.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class Comdlg32 | ||
{ | ||
[DllImport(ExternDll.Comdlg32, ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] | ||
private static extern BOOL PrintDlgW(ref PRINTDLGW_32 lppd); | ||
|
||
[DllImport(ExternDll.Comdlg32, ExactSpelling = true, SetLastError = true, CharSet = CharSet.Unicode)] | ||
private static extern BOOL PrintDlgW(ref PRINTDLGW_64 lppd); | ||
|
||
public static BOOL PrintDlg(ref PRINTDLGW lppd) | ||
{ | ||
if (IntPtr.Size == 4) | ||
{ | ||
if (lppd is PRINTDLGW_32 lppd32) | ||
{ | ||
BOOL result = PrintDlgW(ref lppd32); | ||
lppd = lppd32; | ||
return result; | ||
} | ||
|
||
throw new InvalidOperationException($"Expected {nameof(PRINTDLGW_32)} data struct"); | ||
RussKie marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
if (lppd is PRINTDLGW_64 lppd64) | ||
{ | ||
BOOL result = PrintDlgW(ref lppd64); | ||
lppd = lppd64; | ||
return result; | ||
} | ||
|
||
throw new InvalidOperationException($"Expected {nameof(PRINTDLGW_64)} data struct"); | ||
} | ||
} | ||
} |
134 changes: 134 additions & 0 deletions
134
src/System.Windows.Forms.Primitives/src/Interop/Comdlg32/Interop.PrintDlgW.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using static Interop.User32; | ||
|
||
internal partial class Interop | ||
{ | ||
internal partial class Comdlg32 | ||
{ | ||
// Any change in PRINTDLG_32, should also be in PRINTDLG and PRINTDLG_64 | ||
// x86 requires EXPLICIT packing of 1. | ||
|
||
public unsafe interface PRINTDLGW | ||
{ | ||
uint lStructSize { get; set; } | ||
|
||
IntPtr hwndOwner { get; set; } | ||
IntPtr hDevMode { get; set; } | ||
IntPtr hDevNames { get; set; } | ||
IntPtr hDC { get; set; } | ||
|
||
PD Flags { get; set; } | ||
|
||
ushort nFromPage { get; set; } | ||
ushort nToPage { get; set; } | ||
ushort nMinPage { get; set; } | ||
ushort nMaxPage { get; set; } | ||
ushort nCopies { get; set; } | ||
|
||
IntPtr hInstance { get; set; } | ||
IntPtr lCustData { get; set; } | ||
|
||
IntPtr lpfnPrintHook { get; set; } | ||
IntPtr lpfnSetupHook { get; set; } | ||
|
||
char* lpPrintTemplateName { get; set; } | ||
char* lpSetupTemplateName { get; set; } | ||
|
||
IntPtr hPrintTemplate { get; set; } | ||
IntPtr hSetupTemplate { get; set; } | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode, Pack = 1)] | ||
public unsafe struct PRINTDLGW_32 : PRINTDLGW | ||
{ | ||
public uint _lStructSize; | ||
public IntPtr _hwndOwner; | ||
public IntPtr _hDevMode; | ||
public IntPtr _hDevNames; | ||
public IntPtr _hDC; | ||
public PD _flags; | ||
public ushort _nFromPage; | ||
public ushort _nToPage; | ||
public ushort _nMinPage; | ||
public ushort _nMaxPage; | ||
public ushort _nCopies; | ||
public IntPtr _hInstance; | ||
public IntPtr _lCustData; | ||
public IntPtr _lpfnPrintHook; | ||
public IntPtr _lpfnSetupHook; | ||
public char* _lpPrintTemplateName; | ||
public char* _lpSetupTemplateName; | ||
public IntPtr _hPrintTemplate; | ||
public IntPtr _hSetupTemplate; | ||
|
||
public uint lStructSize { get => _lStructSize; set => _lStructSize = value; } | ||
public IntPtr hwndOwner { get => _hwndOwner; set => _hwndOwner = value; } | ||
RussKie marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
public IntPtr hDevMode { get => _hDevMode; set => _hDevMode = value; } | ||
public IntPtr hDevNames { get => _hDevNames; set => _hDevNames = value; } | ||
public IntPtr hDC { get => _hDC; set => _hDC = value; } | ||
public PD Flags { get => _flags; set => _flags = value; } | ||
public ushort nFromPage { get => _nFromPage; set => _nFromPage = value; } | ||
public ushort nToPage { get => _nToPage; set => _nToPage = value; } | ||
public ushort nMinPage { get => _nMinPage; set => _nMinPage = value; } | ||
public ushort nMaxPage { get => _nMaxPage; set => _nMaxPage = value; } | ||
public ushort nCopies { get => _nCopies; set => _nCopies = value; } | ||
public IntPtr hInstance { get => _hInstance; set => _hInstance = value; } | ||
public IntPtr lCustData { get => _lCustData; set => _lCustData = value; } | ||
public IntPtr lpfnPrintHook { get => _lpfnPrintHook; set => _lpfnPrintHook = value; } | ||
public IntPtr lpfnSetupHook { get => _lpfnSetupHook; set => _lpfnSetupHook = value; } | ||
public char* lpPrintTemplateName { get => _lpPrintTemplateName; set => _lpPrintTemplateName = value; } | ||
public char* lpSetupTemplateName { get => _lpSetupTemplateName; set => _lpSetupTemplateName = value; } | ||
public IntPtr hPrintTemplate { get => _hPrintTemplate; set => _hPrintTemplate = value; } | ||
public IntPtr hSetupTemplate { get => _hSetupTemplate; set => _hSetupTemplate = value; } | ||
} | ||
|
||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] | ||
public unsafe struct PRINTDLGW_64 : PRINTDLGW | ||
{ | ||
public uint _lStructSize; | ||
public IntPtr _hwndOwner; | ||
public IntPtr _hDevMode; | ||
public IntPtr _hDevNames; | ||
public IntPtr _hDC; | ||
public PD _flags; | ||
public ushort _nFromPage; | ||
public ushort _nToPage; | ||
public ushort _nMinPage; | ||
public ushort _nMaxPage; | ||
public ushort _nCopies; | ||
public IntPtr _hInstance; | ||
public IntPtr _lCustData; | ||
public IntPtr _lpfnPrintHook; | ||
public IntPtr _lpfnSetupHook; | ||
public char* _lpPrintTemplateName; | ||
public char* _lpSetupTemplateName; | ||
public IntPtr _hPrintTemplate; | ||
public IntPtr _hSetupTemplate; | ||
|
||
public uint lStructSize { get => _lStructSize; set => _lStructSize = value; } | ||
public IntPtr hwndOwner { get => _hwndOwner; set => _hwndOwner = value; } | ||
public IntPtr hDevMode { get => _hDevMode; set => _hDevMode = value; } | ||
public IntPtr hDevNames { get => _hDevNames; set => _hDevNames = value; } | ||
public IntPtr hDC { get => _hDC; set => _hDC = value; } | ||
public PD Flags { get => _flags; set => _flags = value; } | ||
public ushort nFromPage { get => _nFromPage; set => _nFromPage = value; } | ||
public ushort nToPage { get => _nToPage; set => _nToPage = value; } | ||
public ushort nMinPage { get => _nMinPage; set => _nMinPage = value; } | ||
public ushort nMaxPage { get => _nMaxPage; set => _nMaxPage = value; } | ||
public ushort nCopies { get => _nCopies; set => _nCopies = value; } | ||
public IntPtr hInstance { get => _hInstance; set => _hInstance = value; } | ||
public IntPtr lCustData { get => _lCustData; set => _lCustData = value; } | ||
public IntPtr lpfnPrintHook { get => _lpfnPrintHook; set => _lpfnPrintHook = value; } | ||
public IntPtr lpfnSetupHook { get => _lpfnSetupHook; set => _lpfnSetupHook = value; } | ||
public char* lpPrintTemplateName { get => _lpPrintTemplateName; set => _lpPrintTemplateName = value; } | ||
public char* lpSetupTemplateName { get => _lpSetupTemplateName; set => _lpSetupTemplateName = value; } | ||
public IntPtr hPrintTemplate { get => _hPrintTemplate; set => _hPrintTemplate = value; } | ||
public IntPtr hSetupTemplate { get => _hSetupTemplate; set => _hSetupTemplate = value; } | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.